0
我在另一个网格的第一列中有一个网格,并且希望内部网格的行具有与父网格的行相同的高度。这个想法是,内部网格可以包含我希望能够隐藏的描述(但保持与父网格的行对齐,因为这些描述与父网格中的特定问题相关联)。一个WPF ColumnDefinition不具有可视性财产:(自动调整另一个网格中包含的网格的行的大小
的代码我有thusfar:
<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控件来完成这也是没有问题的。
我会试一试。而且:如何在第一列中使用一个网格并将其大小设置为零。我在开车的时候想到了这款车);但是不知道我是否已经尝试过...... – 2011-04-27 16:41:43
将尺寸设置为零会导致右侧显示非常小的滚动条,因为它仍会尝试显示内容“隐藏”栏......所以这不是一个选项。 – 2011-04-28 07:54:31
@Joep Greuter:不知道我是否理解你的问题是正确的,但为何不在第一列中插入信息文本块,将第一列的widht设置为“Auto”,然后相应地隐藏/显示信息文本块捆绑)。如果我理解你的问题是正确的,这将按照你的意愿行事。然后,您还可以摆脱子网格,使设计更容易。顺便说一下,我已经读过绑定到Active [Width | Height]会减慢布局性能。不知道这是否是一个事实,但我可以想象。因此我会在投入生产之前做一些测试。 – HCL 2011-04-28 08:03:46