Bewerken

Share via


BindingOperations.DisconnectedSource Property

Definition

Gets an object that replaces the DataContext when an item container is removed from the visual tree.

public:
 static property System::Object ^ DisconnectedSource { System::Object ^ get(); };
public static object DisconnectedSource { get; }
static member DisconnectedSource : obj
Public Shared ReadOnly Property DisconnectedSource As Object

Property Value

An object that replaces the DataContext when an item container is removed from the visual tree.

Remarks

Use this property if you need to deal with the DataContext of an item container. An item container is the UI element that displays an item in an ItemsControl. When an ItemsControl is data bound to a collection, an item container is generated for each item. In some cases, item containers are removed from the visual tree. Two typical cases where an item container is removed are when an item is removed from the underlying collection and when virtualization is enabled on the ItemsControl. In these cases, the DataContext property of the item container will be set to the DisconnectedSource property You should check whether the DataContext is equal to the DisconnectedSource before accessing the DataContext in the DataContextChanged event for item containers. For more information about item containers and virtualization, see the remarks in the VirtualizingStackPanel class.

Applies to