Window Height="Auto" not working as expected

Well you can't set the window height to auto, to do this you can use a little trick, name the main main grid container, set its height to auto then bind the window height to the height of the main grid


Old question but an updated answer:

As @Muad'Dib suggested in his answer :

you should set SizeToContent="WidthAndHeight".

If the size of content of window increases more than the screen size, window can overflow from screen. So, you must consider:

MaxWidth="600"
MaxHeight="400"

Set the window's property SizeToContent="WidthAndHeight". This should help.

Tags:

Wpf