I need to get the dynamic Height and Width of my Viewbox The hierarchy of my xaml is like this:
<Grid>
<DockPanel>
<Border>
<ViewBox/>
</border>
</DockPanel>
</Grid>
The Viewbox Width is on "Auto" and the Height is bound to a variable in my Controller. The Class hierarchy is like this: Xaml <--> Controller (the xaml.cs is mostly ignored)
Now my problem is that even in the direct code-behind (xaml.cs), I get 0 as ActualWidth and ActualHeight. If I change the dimension of my mainwindow I don't even get the standard Width and Height not to mention the dynamic one.
If Code-Snippets or information are missing, please tell me.
Here is the image with the red border. You have to look closey at the bottom (a small red Border): enter image description here
Regards Richard
What I have tried:
I tried to get the Dimensions within the Code-Behind: Height/Width (Only get the standard Height and NaN for Width)
ActualHeight/ActualWidth (both are 0)
RenderSize.Height/RenderSize.Width (both are 0)
I also tried the solution in this post: Getting current size of WPF controls It was the reason why I used the RenderSize solution
I end this question because the mainquestion was answered. It was answered in the comments from Kamil Solecki