FrameworkElement.OnRenderSizeChanged(SizeChangedInfo) Method


引发 SizeChanged 事件,将指定的信息用作最终事件数据的一部分。Raises the SizeChanged event, using the specified information as part of the eventual event data.

protected public:
 override void OnRenderSizeChanged(System::Windows::SizeChangedInfo ^ sizeInfo);
protected internal override void OnRenderSizeChanged (System.Windows.SizeChangedInfo sizeInfo);
override this.OnRenderSizeChanged : System.Windows.SizeChangedInfo -> unit
Protected Friend Overrides Sub OnRenderSizeChanged (sizeInfo As SizeChangedInfo)



更改中所涉及新旧大小的详细信息。Details of the old and new size involved in the change.


此方法重写 OnRenderSizeChangedThis method overrides OnRenderSizeChanged. 如果调用此方法,则将重置 ActualWidth 属性、ActualHeight 属性,或同时重置这两种方法,具体取决于在所提供的参数中指定为已更改的内容,并将始终引发事件。If you call this method you will reset the ActualWidth property, the ActualHeight property, or both, depending on what is specified as changed in the supplied arguments, and will you always raise the event.

Notes to Inheritors

不要为典型布局方案重写此方法。Do not override this method for typical layout scenarios. 布局系统以特意异步的方式运行,以确保考虑所有可能的布局排列和度量事例。The layout system operates in a deliberately asynchronous way to assure that all possible layout arrange and measure cases are accounted for. 布局系统替代方法 MeasureOverride(Size)ArrangeOverride(Size) 通常足以满足任何所需的布局自定义。The layout system override methods MeasureOverride(Size) and ArrangeOverride(Size) are usually sufficient for any required layout customization. OnRenderSizeChanged(SizeChangedInfo) 公开为虚拟。OnRenderSizeChanged(SizeChangedInfo) is exposed as a virtual. 您可以重写 OnRenderSizeChanged(SizeChangedInfo) 以便更正与在响应中与控件重新组合相关的输入事件相关的运行时行为更改的异常情况。You can override OnRenderSizeChanged(SizeChangedInfo) to correct for exceptional cases where a run-time behavioral change related to input events combined with control recomposition in response might give inaccurate layout information.

你仍可以在派生类中重写此方法(它是受保护的但不是密封的)。You may still override this method in derived classes (it is protected but not sealed). 始终调用基实现以保留上面提到的行为,除非您有很具体的原因要禁用默认的 WPF 框架级呈现行为。Always call the base implementation to preserve the behavior mentioned above, unless you have very specific reasons for disabling default WPF framework-level rendering behavior. 如果使用标准的 WPF 框架级别布局系统实现,则未能引发 SizeChanged 事件将导致非标准布局行为。Failing to raise the SizeChanged event will cause non-standard layout behavior if using the standard WPF framework-level layout system implementation.

Applies to

See also