gpt4 book ai didi

c# - WPF 使 ListView 高度与 Grid 行高相同

转载 作者:太空宇宙 更新时间:2023-11-03 12:10:17 28 4
gpt4 key购买 nike

我想将网格中一行的高度数据绑定(bind)到我的 ListView 的高度。遗憾的是我无法使 DataBinding 工作。 ListView 位于 Grid 内。非常欢迎任何帮助:)

这些是我的 xaml 代码的一些片段:

<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto" Name="rowDefenitionOne"/>
</Grid.RowDefinitions>

<ListView ItemsSource="{Binding Data}" Height="{Binding ActualHeight,
ElementName=rowDefenitionOne}" Grid.Row="1" Grid.Column="0"
Grid.ColumnSpan="2" Grid.RowSpan="2">
....
</ListView>

最佳答案

您将行高设置为跟随子项的高度(这里只有一个子项 ListView)。行高将遵循该 ListView 的高度。

Making the ListView Height the same as the Grid row height

好吧,ListView 高度与 Grid 行高相同

我想这不是您要找的。

有了那个

<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>

<ListView ItemsSource="{Binding Data}" Grid.Row="1" Grid.Column="0">
....
</ListView>

网格行将采用所有可能的高度,而 ListView 将遵循该行高。

关于c# - WPF 使 ListView 高度与 Grid 行高相同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52653953/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com