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)

参数

oldStyle
Style Style Style Style

旧样式。The old style.

newStyle
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) 的重写可能适用。MeasureOverride(Size) ArrangeOverride(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).

适用于