Grid Row is not expanding after setting Visiblity via Binding Property
I have got following XAML.
<GroupBox Grid.Row="1" Grid.Column="0" Margin="5,5,5,5" Header="Commentary">
<Grid ShowGridLines="True">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Visibility="{Binding Path=UseSecurity, Converter={StaticResource booleanToVisibilityConverter}}">
<Textbox/>
</Grid>
<Grid Grid.Row="1">
<GroupBox Header="Specify common paragraph that applies to all portfolios. (Press F5 to specify commentary for each security, if applicable)" Margin="5,5,5,5" VerticalContentAlignment="Stretch">
<Textbox/>
</GroupBox>
</Grid>
<Grid Grid.Row="2" Visibility="{Binding Path=UseSecurity, Converter={StaticResource booleanToVisibilityConverter}}" IsEnabled="{Binding Path=CommentarySecurityViewModelEnabled}">
<GroupBox Header="Specify commentary for each security specified common paragraph." Margin="5,5,5,5">
<Textbox/>
</GroupBox>
</Grid>
<Grid Grid.Row="3" Visibility="{Binding Path=UseSecurity, Converter={StaticResource booleanToVisibilityConverter}}" IsEnabled="{Binding Path=CommentarySecurityViewModelEnabled}">
<GroupBox Header="Specify commentary for each security specified common paragraph." Margin="5,5,5,5">
<TextBox/>
</GroupBox>
</Grid>
</Grid>
When I set the visibilty of grids on 3rd and 4th row, the 2nd row doens't expand it self to occupy rest of the space. I tried every suggestion I could find including setting each element's visibilty property within the grid but still doesn't wo开发者_开发技巧rk.
Am I doing something wrong or missing something. Can anyone help?
Thanks
Well, what you're actually hiding are the grids within the rows, not the rows themselves. The rows are still there and they still have "star" height, so they're still occupying space. How about using "Auto" height? that way the grid rows will collapse when not in use.
精彩评论