ListBox和WrapPanel性能较慢
本文关键字:性能 WrapPanel ListBox | 更新日期: 2023-09-27 18:12:01
当使用ListBox + WrapPanel在我的WPF中显示ListBox ItemsPanelTemplate中的信息时,我的性能结果非常差。
如果我从ListBox中移除WrapPanel,信息需要大约5秒才能完全显示WrapPanel,它需要大约1.10分钟。
关于如何提高性能有什么建议吗?
配置如下:我的DataTemplate是在App.xaml和使用1边界,网格,20个TextBlocks包裹在6个不同的virtualizingstackpanel。
列表框:
<ListBox Name="myListBox"
Margin="4"
BorderBrush="DarkSlateGray" BorderThickness="1"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ItemsSource="{Binding propList}"
ItemTemplate="{StaticResource myDataTemplate}" >
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
谢谢。
WrapPanel不使用虚拟化,如果您将使用启用了虚拟化的其他面板,则只会创建在UI中可见的元素。