【问题标题】:UserControl scroll performance on tablet device平板设备上的 UserControl 滚动性能
【发布时间】:2012-02-03 07:14:04
【问题描述】:

我有一个用户控件,上面有一组按钮和标签。 宽 1000px 高 70px。

其中最多 50 个显示在 ListBox(或我尝试过的 ListView)中。在我的笔记本上滚动绝对没有问题,但目标硬件是在 Atom Z670(1.5GHz,1 核)上运行 Win7 的平板电脑,配备 Intel GMA600 @ 400MHz。

在这款平板电脑上滚动几乎是不可能的——卡住了。 当我一次显示更少的控件(更高的高度)或只显示其中的一部分(减小 ListView 或 BoxView 的宽度)时,它会变得更好。

我已经在互联网上阅读了一些关于 WPF 和滚动的论文,但它们都没有真正发挥作用。它们似乎主要指向更多的元素。

这是否意味着此硬件无法在全屏宽度和高度上执行平滑滚动,或者我还有什么可以提高滚动性能的方法吗?

CanContentScroll 不会影响此效果 (http://stackoverflow.com/questions/1033841/is-it-possible-to-implement-smooth-scroll-in-a-wpf-listview)

【问题讨论】:

  • 您是否自定义了您的列表框?如果有,请尝试将 IsVirtualizing 属性设置为 true:msdn.microsoft.com/en-us/library/…。默认模板默认 IsVirtualizing 为 true,但如果您使用自定义模板,则需要显式设置该值。
  • ListView 和 ListBox 都是系统默认设置...我尝试了 CanContendScroll tr​​ue/false 但没有真正的区别...反应缓慢,除了“流畅”之外的一切。你认为硬件可能是问题还是一定是我的错?

标签: wpf windows performance scroll tablet


【解决方案1】:

如果您不进行虚拟化,自动化可能会破坏大视图树。所以尝试删除它。

/// <summary>
/// List View without Automation
/// Fixes the bug with tablet and touch screens
/// </summary>
public class CustomListView : ListView
{
    protected override AutomationPeer OnCreateAutomationPeer()
    {
        System.Diagnostics.Debug.Print("Automation Again");
        return null;
    }

    protected override DependencyObject GetContainerForItemOverride()
    {
        return new NoAutomatioListViewItem();
    }

}

class NoAutomatioListViewItem : ListViewItem
{
    protected override AutomationPeer OnCreateAutomationPeer()
    {
        return null;
    }
}

如果不是这样,自动化将为每个项目和一个大列表创建整个视图树(15k 项目足以看到问题)它会变得迟缓。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-05-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-31
    相关资源
    最近更新 更多