FrameworkElement.OnStyleChanged(Style, Style) FrameworkElement.OnStyleChanged(Style, Style) FrameworkElement.OnStyleChanged(Style, Style) FrameworkElement.OnStyleChanged(Style, Style) Method


在這個項目上使用的樣式變更時叫用,如此將使配置失效。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)


Style Style Style Style

舊樣式。The old style.

Style Style Style 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. 覆寫OnStyleChanged(Style, Style)可能適合如果您ArrangeOverride(Size) / MeasureOverride(Size)實作刻意將最佳化,或支援部分更新,但仍然會想要更直接將變更套用至樣式。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).