If my window gets re-sized, the menu control re-sizes with it. And it looks very nasty when that happens. How can I prevent this? I’m looking for a property called ‘re size’ but there isn’t any.
[Edit]
<Menu Canvas.Left="0" Canvas.Top="0" Name="menu1" Margin="0,0,0,384">
<MenuItem Header="File" StaysOpenOnClick="True" FontFamily="Arial" VerticalAlignment="Center">
<MenuItem Click="Open_Click" IsEnabled="True">
<MenuItem.Header>
<TextBlock Text="Open" VerticalAlignment="Center"/>
</MenuItem.Header>
</MenuItem>
</MenuItem>
</Menu>
[/Edit]
That is because of
MarginProperty. Just remove it and setVerticalAlignment="Top"for Menu.Margin="0,0,0,384"means that there are 384 units of length between Menu and bottom bound of Menu’s visual parent. Thus it means that Menu height is dependent on it’s visual parent height, which is dependent on window height in your case.Specifying
VerticalAlignment="Top"will lead to the following: Menu will be situated as high as possible in visual parent bounds and will have as small height as it possible to fit it’s contents: “File” text in your case. If you think that’s too small you can do 2 things: specifyHeightfor Menu or, which is much more sensible, specifyPaddingfor Menu. One would prefer specifyingPaddingbecause it will guarantee that Menu height will be enough to fit contents, no matter what FontSize or FontFamily etc. will be the MenuItem text.