PropertySet PropertySet PropertySet PropertySet Class

Represents a property set, which is a set of PropertyValue objects with string keys.

Syntax

Declaration

public sealed class PropertySetpublic sealed class PropertySetPublic NotInheritable Class PropertySet

Remarks

This class implements a map (the IMap<K, V> interface) with keys of type String and values of type PropertyValue. The PropertySet type enables various Windows Runtime APIs to return a collection of mixed values that can still be iterated or inspected using the common collection APIs of PropertySet, which match those of IMap<K, V>, IDictionary<TKey,TValue>, or JavaScript collection and enumeration techniques, depending on which language your app uses.

PropertyValue is a class that supports a large number of static Create* methods that create a deliberately untyped value from an input that's typically a value type or primitive (Boolean, numbers and so on) or an array of those values. Once one of the static PropertyValue methods is called, its return value can be treated as a PropertyValue instance (however the Create* methods technically return an Object if you look at the signatures).

However, you don't typically use a PropertySet in a way that requires you to fill the PropertyValue values in the set yourself. Instead, you typically get a filled-in PropertySet as a return value from a Windows Runtime API that's providing a collection where the value types within it might be mixed, but are still related to each other by origin or scenario. For example, the LocalSettings and RoamingSettings values that you get when you retrieve app data are of type ApplicationDataContainer, and each contains a PropertySet as its Values property value. When you interact with app data that's storing settings, you typically get the collection from Values. Then you can:

For scenarios like working with app data, when you have a PropertySet you have it by reference, so if you add items to the PropertySet using Add/Insert(System.String,System.Object) these items will be added to the app data, and removing items removes them from app data. All such changes are then shared through the app data mechanisms, if they're made to the RoamingSettings.

There are other Windows Runtime APIs that use a PropertySet value as a direct value rather than wrapped in another class like ApplicationDataContainer. For example, Properties returns a PropertySet.

Various properties that report info from media and devices use PropertySet, for example Properties. However, there are other media/devices property sets that don't use PropertySet and instead use MediaPropertySet, because the identifier for those properties is better represented when keyed as a GUID rather than a string.

In many cases where a Windows Runtime API uses a PropertySet as a value, it's actually shown as IPropertySet in the signatures. PropertySet can be considered the practical implementation of IPropertySet that's ready for use by app code. JavaScript code can treat any IPropertySet value as if it implemented the PropertySet prototypes.

Collection member lists

For JavaScript, PropertySet supports using an index to access items.

Constructors summary

Creates and initializes a new instance of the property set.

Properties summary

Gets the number of items contained in the property set.

Methods summary

Removes all items from the property set.

Returns an iterator to enumerate the items in the property set.

Gets an immutable view of the property set.

Indicates whether the property set has an item with the specified key.

Adds an item to the property set.

Retrieves the value for the specified key.

Removes an item from the property set.

Events summary

Occurs when the observable map has changed.

Constructors

  • PropertySet()
    PropertySet()
    PropertySet()
    PropertySet()

    Creates and initializes a new instance of the property set.

    public PropertySet()public PropertySet()Public Function PropertySet() As

Properties

  • Size
    Size
    Size
    Size

    Gets the number of items contained in the property set.

    public uint Size { get; }public uint Size { get; }Public ReadOnly Property Size As uint

    Property Value

    • uint
      uint
      uint
      uint

      The number of items in the property set.

Methods

  • Clear()
    Clear()
    Clear()
    Clear()

    Removes all items from the property set.

    public void Clear()public void Clear()Public Function Clear() As void
  • First()
    First()
    First()
    First()

    Returns an iterator to enumerate the items in the property set.

    public IIterator<IKeyValuePair<string, object>> First()public IIterator<IKeyValuePair<string, object>> First()Public Function First() As IIterator( Of IKeyValuePairstring, object )

    Returns

    • The iterator. The current position of the iterator is index 0, or the end of the property set if the property set is empty.

  • GetView()
    GetView()
    GetView()
    GetView()

    Gets an immutable view of the property set.

    public IMapView<string, object> GetView()public IMapView<string, object> GetView()Public Function GetView() As IMapView( Of string, object )

    Returns

    • The immutable view.

  • HasKey(System.String)
    HasKey(System.String)
    HasKey(System.String)
    HasKey(System.String)

    Indicates whether the property set has an item with the specified key.

    public bool HasKey(System.String key)public bool HasKey(System.String key)Public Function HasKey(key As System.String) As bool

    Parameters

    • key
      System.String
      System.String
      System.String
      System.String

      The key.

    Returns

    • bool
      bool
      bool
      bool

      True if the property set has an item with the specified key; otherwise, false.

  • Insert(System.String,System.Object)
    Insert(System.String,System.Object)
    Insert(System.String,System.Object)
    Insert(System.String,System.Object)

    Adds an item to the property set.

    public bool Insert(System.String key,System.Object value)public bool Insert(System.String key,System.Object value)Public Function Insert(key As System.String,value As System.Object) As bool

    Parameters

    • key
      System.String
      System.String
      System.String
      System.String

      The key to insert.

    • value
      System.Object
      System.Object
      System.Object
      System.Object

      The value to insert.

    Returns

    • bool
      bool
      bool
      bool

      True if the method replaces a value that already exists for the key; false if this is a new key.

  • Lookup(System.String)
    Lookup(System.String)
    Lookup(System.String)
    Lookup(System.String)

    Retrieves the value for the specified key.

    public object Lookup(System.String key)public object Lookup(System.String key)Public Function Lookup(key As System.String) As object

    Parameters

    • key
      System.String
      System.String
      System.String
      System.String

      The key.

    Returns

    • object
      object
      object
      object

      The value, if an item with the specified key exists. Use the HasKey method to determine whether the key exists.

  • Remove(System.String)
    Remove(System.String)
    Remove(System.String)
    Remove(System.String)

    Removes an item from the property set.

    public void Remove(System.String key)public void Remove(System.String key)Public Function Remove(key As System.String) As void

    Parameters

    • key
      System.String
      System.String
      System.String
      System.String

      The key.

    Remarks

    For the C# or Microsoft Visual Basic version of the Remove method, see Remove(System.String).

Events

  • MapChanged
    MapChanged
    MapChanged
    MapChanged

    Occurs when the observable map has changed.

    public event MapChangedEventHandler MapChangedpublic event MapChangedEventHandler MapChangedPublic Event MapChanged

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.FoundationContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.ThreadingAttribute
Windows.Foundation.Metadata.DualApiPartitionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.ActivatableAttribute

Details

Assembly

Windows.Foundation.Collections.dll