gpt4 book ai didi

c# - WPF ListView 虚拟化。如何禁用 ListView 虚拟化?

转载 作者:太空狗 更新时间:2023-10-29 21:08:48 27 4
gpt4 key购买 nike

我在使用自定义 ListView 时遇到了一些问题(滚动 ListView 时内部的复选框丢失了它们的状态)。我可以在不枚举可视化树的情况下禁用 ListView 虚拟化吗?

<ListView>
<ListView.Resources>
<Style TargetType="GridViewColumnHeader">
<Setter Property="Visibility" Value="Collapsed" />
</Style>
</ListView.Resources>
<ListView.View>
<GridView>
<GridViewColumn Header="Address">
<GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox Content="{Binding Address}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Name">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>

最佳答案

正如 H.B. 所说在 their answer here :

Set VirtualizingStackPanel.IsVirtualizing to false on the ListView or set a normal StackPanel as the ListView.ItemsPanel.

<ListView VirtualizingStackPanel.IsVirtualizing="False"/>

<ListView>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel></StackPanel>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>

关于c# - WPF ListView 虚拟化。如何禁用 ListView 虚拟化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23371810/

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