FrameworkElement.OnStyleChanged(Style, Style) 方法

定義

在這個項目上使用的樣式變更時叫用,如此將使配置失效。Invoked when the style in use on this element changes, which will invalidate the layout.

protected public:
 virtual void OnStyleChanged(System::Windows::Style ^ oldStyle, System::Windows::Style ^ newStyle);
protected internal virtual void OnStyleChanged (System.Windows.Style oldStyle, System.Windows.Style newStyle);
abstract member OnStyleChanged : System.Windows.Style * System.Windows.Style -> unit
override this.OnStyleChanged : System.Windows.Style * System.Windows.Style -> unit
Protected Friend Overridable Sub OnStyleChanged (oldStyle As Style, newStyle As Style)

參數

oldStyle
Style

舊樣式。The old style.

newStyle
Style

新樣式。The new style.

備註

這個方法有一個預設的實值,它會設定會注意樣式已變更條件的內部旗標。This method has a default implementation that sets an internal flag that notes the style changed condition.

給繼承者的注意事項

您通常不需要覆寫此方法。You should not typically have to override this method. 任何牽涉到量值或排列變更之樣式的變更,都已觸發另一個轉譯週期,假設 ArrangeOverride(Size) / MeasureOverride(Size)或預設值的典型執行。Any change to a style that involves a measure or arrange change would already trigger another render cycle, assuming a typical implementation of ArrangeOverride(Size) / MeasureOverride(Size), or the defaults. 如果您的 ArrangeOverride(Size) / MeasureOverride(Size) 的實作為故意優化或支援部分更新,但仍想要更直接將變更套用至樣式,則 OnStyleChanged(Style, Style) 的覆寫可能很適合。Overrides of OnStyleChanged(Style, Style) might be appropriate if your ArrangeOverride(Size) / MeasureOverride(Size) implementations were deliberately optimizing or supporting partial updates, but still wanted to apply changes to styles more directly. (部分更新會嘗試避免多個累加式呼叫 Measure(Size),並在任何子專案上 Arrange(Rect))。(The partial updates would be an attempt to avoid multiple incremental calls to Measure(Size) and Arrange(Rect) on any child elements).

適用於