gpt4 book ai didi

wpf - WPF 中的宽度和实际宽度有什么区别?

转载 作者:行者123 更新时间:2023-12-02 23:33:00 30 4
gpt4 key购买 nike

我目前正在 WPF 中使用 Panel,我注意到关于 WidthHeight 属性,还有两个其他名为 ActualWidthActualHeight 的属性。

ActualWidth

Gets the rendered width of this element. This is a dependency property. (Inherited from FrameworkElement.)

Width

Gets or sets the width of the element. This is a dependency property. (Inherited from FrameworkElement.)

引用:MSDN

谁能指出两者之间的差异以及何时使用其中之一?

最佳答案

宽度/高度请求的或布局尺寸。如果您设置为“自动”,则当您在后面的代码中访问该属性时,该值为 double.NaN

ActualWidth/ActualHeightRenderSize.Width/RenderSize.Height 均返回元素的渲染大小,如下所示RenderSize 的类型为Size。如果您想要/需要项目的实际大小,请使用这些属性中的任何一个。

关于wpf - WPF 中的宽度和实际宽度有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/607827/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com