You have several options that you can do this by calling Window.Measure and Window.Arrange so that all values ββare calculated, or you can get these values ββin the Window.Loaded event. The same problem has already been discussed on this issue .
If you determine the size of the content:
window.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); window.Arrange(new Rect(0, 0, window.DesiredWidth, window.DesiredHeight));
If you are using explicit window size:
window.Measure(new Size(Width, Height)); window.Arrange(new Rect(0, 0, window.DesiredWidth, window.DesiredHeight));
or
public MyWindow() { Loaded += delegate {
source share