DependencyObjectCollection DependencyObjectCollection DependencyObjectCollection DependencyObjectCollection Class

Definition

Implements a practical collection class that can contain DependencyObject items.

public : class DependencyObjectCollection : DependencyObject
struct winrt::Windows::UI::Xaml::DependencyObjectCollection : DependencyObject
public class DependencyObjectCollection : DependencyObject
Public Class DependencyObjectCollection Inherits DependencyObject
Inheritance
DependencyObjectCollectionDependencyObjectCollectionDependencyObjectCollectionDependencyObjectCollection
Attributes

Windows 10 requirements

Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

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 in depth.

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 with a DependencyObject constraint.

Constructors

DependencyObjectCollection() DependencyObjectCollection() DependencyObjectCollection() DependencyObjectCollection()

Initializes a new instance of the DependencyObjectCollection class.

Properties

Dispatcher Dispatcher Dispatcher Dispatcher

Gets the CoreDispatcher that this object is associated with. The CoreDispatcher represents a facility that can access the DependencyObject on the UI thread even if the code is initiated by a non-UI thread.

(Inherited from DependencyObject)
Size Size Size Size

Gets the size (count) of the collection.

Methods

Append(DependencyObject) Append(DependencyObject) Append(DependencyObject) Append(DependencyObject)

Adds a new item to the collection.

Clear() Clear() Clear() Clear()

Removes all items from the collection.

ClearValue(DependencyProperty) ClearValue(DependencyProperty) ClearValue(DependencyProperty) ClearValue(DependencyProperty)

Clears the local value of a dependency property.

(Inherited from DependencyObject)
First() First() First() First()

Returns the iterator for iteration over the items in the collection.

GetAnimationBaseValue(DependencyProperty) GetAnimationBaseValue(DependencyProperty) GetAnimationBaseValue(DependencyProperty) GetAnimationBaseValue(DependencyProperty)

Returns any base value established for a dependency property, which would apply in cases where an animation is not active.

(Inherited from DependencyObject)
GetAt(UInt32) GetAt(UInt32) GetAt(UInt32) GetAt(UInt32)

Returns the DependencyObject located at the specified index.

GetMany(UInt32, DependencyObject[]) GetMany(UInt32, DependencyObject[]) GetMany(UInt32, DependencyObject[]) GetMany(UInt32, DependencyObject[])

Retrieves multiple elements in a single pass through the iterator.

GetValue(DependencyProperty) GetValue(DependencyProperty) GetValue(DependencyProperty) GetValue(DependencyProperty)

Returns the current effective value of a dependency property from a DependencyObject.

(Inherited from DependencyObject)
GetView() GetView() GetView() GetView()

Gets an immutable view into the collection.

IndexOf(DependencyObject, UInt32) IndexOf(DependencyObject, UInt32) IndexOf(DependencyObject, UInt32) IndexOf(DependencyObject, UInt32)

Retrieves the index of the specified item.

InsertAt(UInt32, DependencyObject) InsertAt(UInt32, DependencyObject) InsertAt(UInt32, DependencyObject) InsertAt(UInt32, DependencyObject)

Inserts the specified item at the specified index.

ReadLocalValue(DependencyProperty) ReadLocalValue(DependencyProperty) ReadLocalValue(DependencyProperty) ReadLocalValue(DependencyProperty)

Returns the local value of a dependency property, if a local value is set.

(Inherited from DependencyObject)
RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback) RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback) RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback) RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback)

Registers a notification function for listening to changes to a specific DependencyProperty on this DependencyObject instance.

(Inherited from DependencyObject)
RemoveAt(UInt32) RemoveAt(UInt32) RemoveAt(UInt32) RemoveAt(UInt32)

Removes the item at the specified index.

RemoveAtEnd() RemoveAtEnd() RemoveAtEnd() RemoveAtEnd()

Removes the last item in the collection.

ReplaceAll(DependencyObject[]) ReplaceAll(DependencyObject[]) ReplaceAll(DependencyObject[]) ReplaceAll(DependencyObject[])

Initially clears the collection, then inserts the provided array as new items.

SetAt(UInt32, DependencyObject) SetAt(UInt32, DependencyObject) SetAt(UInt32, DependencyObject) SetAt(UInt32, DependencyObject)

Sets the value at the specified index to the DependencyObject value specified.

SetValue(DependencyProperty,Object) SetValue(DependencyProperty,Object) SetValue(DependencyProperty,Object) SetValue(DependencyProperty,Object)

Sets the local value of a dependency property on a DependencyObject.

(Inherited from DependencyObject)
UnregisterPropertyChangedCallback(DependencyProperty,Int64) UnregisterPropertyChangedCallback(DependencyProperty,Int64) UnregisterPropertyChangedCallback(DependencyProperty,Int64) UnregisterPropertyChangedCallback(DependencyProperty,Int64)

Cancels a change notification that was previously registered by calling RegisterPropertyChangedCallback.

(Inherited from DependencyObject)

Events

VectorChanged VectorChanged VectorChanged VectorChanged

Occurs when the contents of the collection changes.

See also