Just Code‎ > ‎

WPF - Make window size adjust automatically to its content

posted Jan 24, 2012, 5:44 AM by Peter Henell   [ updated Jan 25, 2012, 5:13 AM ]
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"
        >
Comments