FrameworkElement.DataContextChanged 事件


這個項目的資料內容變更時發生。Occurs when the data context for this element changes.

 event System::Windows::DependencyPropertyChangedEventHandler ^ DataContextChanged;
public event System.Windows.DependencyPropertyChangedEventHandler DataContextChanged;
member this.DataContextChanged : System.Windows.DependencyPropertyChangedEventHandler 
Public Custom Event DataContextChanged As DependencyPropertyChangedEventHandler 


如需資料內容和資料系結的說明,請參閱資料系結總覽For an explanation of data contexts and data binding, see Data Binding Overview.


當元素的 DataContext 變更時,此專案上的所有資料系結屬性可能會受到影響。When the DataContext for an element changes, all data-bound properties on this element are potentially affected. 這適用于邏輯樹狀結構中目前專案之子專案的任何專案,該專案會繼承資料內容,以及目前的專案本身。This applies to any elements that are child elements of the current element in the logical tree, which inherit the data context, and also the current element itself. 所有這類現有的系結都必須重新解讀新的 DataContext,而且會重新評估系結結果。All such existing bindings must re-interpret the new DataContext and will reevaluate the binding results. 資料系結引擎對於這些 reevaluations 的順序不具決定性,相對於引發 DataContextChanged 事件。The data binding engine is not deterministic about the order of these reevaluations, relative to the raising of the DataContextChanged event. Reevaluations 可以發生在事件之前、事件之後,或任何混合。The reevaluations can occur before the event, after the event, or in any mixture.