Consider the following:
Let's say the Window is 1024x768 and the ViewBox fills the entire window, this means the TextBox is really large on the screen.
I want to get the size of the TextBox as it is currently on the screen. If I get DesiredSize or ActualSize or even RenderedSize I always get 100.
Any suggestions?
Update: I could probably get the ActualWidth
of the ViewBox and divide it by the ActualWidth
of it's child which would give me the current scale factor and expose that as a property somehow but I'm not sure that's the best way to do it.
This is how you get the
ScaleTransform
theViewBox
exerts on its children:Here
viewBox
is the ViewBox that textbox sits in. Then you can just multiplyscale.ScaleX * textBox.ActualWidth
and you get the size in Screen coordinatesBut it gets even easier! To get that textbox's size directly in Screen Coordinates you do: