Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DependencyObjectCollection class

Applies to Windows and Windows Phone

Implements a practical collection class that can contain DependencyObject items.

Inheritance

Object
  DependencyObject
    DependencyObjectCollection

Syntax


public class DependencyObjectCollection : DependencyObject,
    IObservableVector<DependencyObject>,
    IList<DependencyObject>,
    IEnumerable<DependencyObject>

Attributes

[MarshalingBehavior(Agile)]
[Threading(Both)]
[Version(0x06030000)]
[WebHostHidden()]

Members

The DependencyObjectCollection class has these types of members:

Constructors

The DependencyObjectCollection class has these constructors.

ConstructorDescription
DependencyObjectCollection Initializes a new instance of the DependencyObjectCollection class.

 

Events

The DependencyObjectCollection class has these events.

EventDescription
VectorChanged Occurs when the contents of the collection changes.

 

Methods

The DependencyObjectCollection class has these methods. It also inherits methods from the Object class.

MethodDescription
Add [C#, VB]Adds a new item to the collection.
Append [C++]Adds a new item to the collection.
Clear Removes all items from the collection.
ClearValue Clears the local value of a dependency property. (Inherited from DependencyObject)
Contains [C#, VB]Determines whether an element is in the collection.
CopyTo [C#, VB]Copies the elements of the collection to an array, starting at a particular array index.
First [C++]Returns the iterator for iteration over the items in the collection.
GetAnimationBaseValue Returns any base value established for a dependency property, which would apply in cases where an animation is not active. (Inherited from DependencyObject)
GetAt [C++]Returns the DependencyObject located at the specified index.
GetMany [C++]Retrieves multiple elements in a single pass through the iterator.
GetValue Returns the current effective value of a dependency property from a DependencyObject. (Inherited from DependencyObject)
GetView [C++]Gets an immutable view into the collection.
IndexOf [C++]Retrieves the index of the specified item.
IndexOf [C#, VB]Determines the index of a specific item in the collection.
Insert [C#, VB]Inserts an item into the collection at the specified index.
InsertAt [C++]Inserts the specified item at the specified index.
ReadLocalValue Returns the local value of a dependency property, if a local value is set. (Inherited from DependencyObject)
Remove [C#, VB]Removes the first occurrence of a specific object from the collection.
RemoveAt [C++]Removes the item at the specified index.
RemoveAt [C#, VB]Removes the element at the specified index of the collection.
RemoveAtEnd [C++]Removes the last item in the collection.
ReplaceAll [C++]Initially clears the collection, then inserts the provided array as new items.
SetAt [C++]Sets the value at the specified index to the DependencyObject value specified.
SetValue Sets the local value of a dependency property on a DependencyObject. (Inherited from DependencyObject)

 

Properties

The DependencyObjectCollection class has these properties.

PropertyAccess typeDescription

Count [C#, VB]

Read-onlyGets the number of elements contained in the collection.

Dispatcher

Read-onlyGets the CoreDispatcher that this object is associated with. (Inherited from DependencyObject)

IsReadOnly [C#, VB]

Read-onlyGets a value indicating whether the collection is read-only.

Item [C#, VB]

Read/writeGets or sets the element at the specified index.

Size [C++]

Read-onlyGets the size (count) of the collection.

 

Remarks

The purpose of the DependencyObjectCollection class is mainly to support the tooling and portability of behaviors. Behaviors are a technique for defining certain basic interactions of a UI element entirely in XAML, without requiring an event handler and code-behind.

If you're interested in implementing a business object class that supports collection-changed notifications you should use ObservableCollection or one of the interface patterns that supports changed events. For more info see Data binding with XAML.

Enumerating the collection in C# or Microsoft Visual Basic

A DependencyObjectCollection is enumerable, so you can use language-specific syntax such as foreach in C# to enumerate the items in the collection. The compiler does the type-casting for you and you won't need to cast to IEnumerable<DependencyObject> explicitly. If you do need to cast explicitly, for example if you want to call GetEnumerator, cast to IEnumerable<T> with a DependencyObject constraint.

Requirements

Minimum supported client

Windows 8.1 [Windows Store apps only]

Minimum supported server

Windows Server 2012 R2 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Xaml
Windows::UI::Xaml [C++]

Metadata

Windows.winmd

See also

DependencyObject
IObservableVector(DependencyObject)
IVector(DependencyObject)
IIterable(DependencyObject)
IList<T>

 

 

Show:
© 2014 Microsoft