通过绑定属性设置可见性后,网格行未展开

时间:2011-06-16 15:32:30

标签: wpf xaml

我已经关注了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>

当我在第3和第4行设置网格的可见性时,第2行不会自我展开以占据剩余的空间。我尝试了我能找到的每一个建议,包括在网格中设置每个元素的可见性属性,但仍然不起作用。

我做错了什么或遗失了什么。有人可以帮忙吗?

由于

1 个答案:

答案 0 :(得分:1)

嗯,你实际隐藏的是行内的网格,而不是行本身。行仍然存在,它们仍然具有“星”高度,因此它们仍然占据空间。如何使用“自动”高度?这样,网格行在不使用时会崩溃。