Is it possible for a WPF control to have an ActualWidth and ActualHeight if it has never been rendered?

前端 未结 1 822
逝去的感伤
逝去的感伤 2021-01-05 22:37

I need a Viewport3D for the sole purpose of doing geometric calculations using Petzold.Media3D.ViewportInfo. I would prefer not to have to place it

相关标签:
1条回答
  • 2021-01-05 22:56

    From MSDN topic for the ActualWidth property:

    This property is a calculated value based on other width inputs, and the layout system. The value is set by the layout system itself, based on an actual rendering pass, and may therefore lag slightly behind the set value of properties such as Width that are the basis of the input change.

    So, this sounds like a rendering pass is necessary for the property to be set. However, you could try to call Measure(Size) and then Arrange(Rect) to simulate the layout process. Maybe this is already sufficient.

    0 讨论(0)
提交回复
热议问题