WPF - Make window size adjust automatically to its content

Post date: Jan 24, 2012 1:44:20 PM

Use the SizeToContent property of the Window to make it adjust to the content it contains.

If you set Width and Height to Auto, the window will get a default size which is not what you want.

<Window x:Class="ConnectionStringCreatorGUI.ConnectionStringBuilderWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Choose connection" SizeToContent="WidthAndHeight" >