【发布时间】:2011-08-13 22:43:46
【问题描述】:
我在另一个网格的第一列中有一个网格,并且希望内部网格的行与父网格的行具有相同的高度。这个想法是内部网格可以包含我希望能够隐藏的描述(但与父网格的行保持对齐,因为这些描述与父网格中的某些问题相关联)。 WPF ColumnDefinition 没有 Visibility 属性:(
到目前为止我的代码:
<Grid ShowGridLines="true" Name="gridje">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" Name="row0"/>
<RowDefinition Height="Auto" Name="row1"/>
<RowDefinition Height="Auto" Name="row2"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid Grid.Row="0" Grid.RowSpan="3" ShowGridLines="true">
<Grid.RowDefinitions>
<RowDefinition Height="{Binding ElementName=row0, Path=ActualHeight, Mode=OneWay}"/>
<RowDefinition Height="{Binding ElementName=row1, Path=ActualHeight, Mode=OneWay}"/>
<RowDefinition Height="{Binding ElementName=row2, Path=ActualHeight, Mode=OneWay}"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0">Joepie</TextBlock>
<TextBlock Grid.Row="2">Joepie</TextBlock>
</Grid>
<TextBlock Grid.Row="0" Grid.Column="1" TextWrapping="WrapWithOverflow">Klaasje daskljf askldfas dfasjkl dfhklasjdfh askljdfh askljdfh h askljdfh klasdfh alsjkdfh askldfh askljfh alsdjkfh asklfh </TextBlock>
<TextBlock Grid.Row="1" Grid.Column="1" TextWrapping="WrapWithOverflow">Klaasje daskljf askldfas dfasjkl dfhklasjdfh askljdfh askljdfh h askljdfh klasdfh alsjkdfh askldfh askljfh alsdjkfh asklfh</TextBlock>
<TextBlock Name="textb" Grid.Row="2" Grid.Column="1" TextWrapping="WrapWithOverflow" Text="{Binding ElementName=row0, Path=ActualHeight, Mode=OneWay}"></TextBlock>
<Button Content="Button" Grid.Column="1" Grid.Row="2" Height="23" HorizontalAlignment="Left" Margin="66,173,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />
</Grid>
奇怪的是,在 VS2010 的设计模式下,一切正常,但一旦运行,所有实际高度属性都保持为零。
对此的任何帮助将不胜感激。并且也许使用一些其他的 WPF 控件来完成这个也没有问题。
【问题讨论】:
标签: wpf