Search code examples
wpfxamlresizetitlesizetocontent

Making SizeToContent take Title into account


Here's the XAML code for a very simple WPF window:

<Window x:Class="TitleTester.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Long, verbose, unabridged title" SizeToContent="WidthAndHeight">
    <Grid>
        <Label>Short text</Label>
    </Grid>
</Window>

When I open this window, the text Short text is displayed in full; however, the title bar only displays L... (the first letter of Long, verbose, unabridged title). I would like the opened window to be wide enough to display the full title, and no wider. Is there a way to do this?


Solution

  • This thread should help you solve your issue : http://social.msdn.microsoft.com/Forums/en/wpf/thread/b9ea5bf1-04f2-47c9-bf7c-a2a804e105a4