【问题标题】:ListBox and WrapPanel slow performanceListBox 和 WrapPanel 性能下降
【发布时间】:2016-10-06 09:47:28
【问题描述】:

当使用 ListBox + WrapPanel 在 ListBox ItemsPanelTemplate 内的 WPF 中显示信息时,我的性能结果非常差。

如果我从 ListBox 中删除 WrapPanel,信息大约需要 5 秒 才能完全显示在 WrapPanel 中大约需要 1.10 分钟。

关于如何提高性能的任何提示?

配置是: 我的 DataTemplate 位于 App.xaml 中,并使用 1 个边框、网格、20 个文本块包裹在 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>

谢谢。

【问题讨论】:

标签: c# wpf wpf-controls


【解决方案1】:

WrapPanel 不使用虚拟化,如果您将使用启用了虚拟化的其他面板,则只会创建 UI 中可见的元素。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-08-08
  • 2012-06-23
  • 1970-01-01
  • 2016-04-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多