Silverlight Expander Control does not expand evenly
I'm trying to use the Silverlight expander control and the content of the expander does not resize evenly to the rest of the content when expanded. any ideas? this is what it looks like
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<toolkit:Expander ExpandDirection="Right" Grid.Column="0" IsExpanded="True">
<toolkit:Expander.Header>
<TextBlock Text="Title" Foreground="Black" />
</toolkit:Expander.Header>
<toolkit:Expander.Content>
<Controls:Grid x:Name="LayoutRoot" ShowGridLines="True">
<ContentControl Navigation:ContentArea.AreaName="shellView" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" />
<ContentControl x:Name="loaderView" HorizontalContentAlignment="Stretch" Verti开发者_C百科calContentAlignment="Stretch" />
</Controls:Grid>
</toolkit:Expander.Content>
</toolkit:Expander>
<ContentControl Grid.Column="1" x:Name="testPage" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" />
</Grid>
The result is the expander shows about 30% of the available area but i want it to show 50%
You've got the Expander sitting it column #1 of a 2-column Grid. The fact that the column's width is set to Auto, and the other columns width is *, means that it will only take the space it needs (and giving its children a Stretch alignment will not override this, as there is no fixed space to expand into).
Just removing that Auto should fix your problem, and make the Expander content fill 50% of the space available to the root Grid:
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
That's the equivalent of giving each column equal width:
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
精彩评论