WPF set menu height to fit?
c#, visual-studio-2010, wpf
Solution
Try using this:
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
This will cause the first row to shrink to only as much space as is necessary to display the content.
Problem
In WPF, how can one set the height of menu to fit , instead of like this below where the gray shade goes down ``` <Window x:Class="XAML_Concepts.GridLayout" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="GridLayout" Height="600" Width="800"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="7*"/> <ColumnDefinition Width="3*"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition Height="1*"/> </Grid.RowDefinitions> <Menu IsMainMenu="True" Grid.Row="0" Grid.ColumnSpan="2" Grid.RowSpan="1" > <MenuItem Header="File"> <MenuItem Header="_New"></MenuItem> <MenuItem Header="_Open"></MenuItem> </MenuItem> <MenuItem Header="Edit"></MenuItem> </Menu> </Grid> </Window> ``` I just need it to look a normal menu, like one in windows explorer, without any gray shading below. I have tried manipulating row size, menu size, and several other attributes but I' missing something simple. When I set the Grid''s row height to , say 20px , this is what I get which I am not pleased with because A-I don't want to enter an absolute height and B-The shade doesn't look right, it is like the background gradient is smearing.. Thanks