English 中文(简体)
WPF 树木观测和虚拟化(调查与数据)
原标题:WPF TreeView and Virtualization(UI & Data)
  • 时间:2011-11-18 13:31:03
  •  标签:
  • c#
  • .net
  • wpf

我有以下等级结构:

 class User
  {
     public List<Contract> Contracts{get;set;}
  }

  class Contract
  {
     public List<Group> Groups{get;set;}
  }

  class Group
  {
     public List<Article> Articles{get;set;}
  }

  class Article
  {
      public string Name{get;set;}
      public string Id{get;set;}
  }

每个用户都有与他有关的一些合同,每项合同都有一些与他相关的团体,每个集团都有一些条款。

我以这种直观方式在WPF中使用一 Tree树(如http://www.codeproject.com/KB/WPF/TreeViewWithCheckBoxes.aspx” rel=“nofollow”http://www.codeproject.com/KB/WPF/TreeViewWithCheckBoxes.aspx):

(每个用户点击在树冠中显示这一结构):

>Contract1
  >Group1
    >Article1
    >Article2
    >Article3
    >Article4
    ...
  >Group2
  >Group3
  ------------
  Add Button
  Remove Button
  -------------

用户利用这一先例的筛选,只能通过检查文章或合同或团体,点击Addutton,或点击Remove Button,将这些条款或合同或团体列入他的账户。

问题是,每个集团都有成千上万篇文章,我不想一劳永逸,因为这会减缓事情。

您能想到处理该问题的更好方式?

问题回答

由于WPF 3.5 SP1,有VirtualizationMode.Recycling 虚拟化模式,允许再利用项目集装箱,并且每次用户都不会制造新的物品控制。

When VirtualizationMode is set to Recycling, the VirtualizingStackPanel reuses item containers instead of creating a new one each time.

提 出

<TreeView
    VirtualizingStackPanel.IsVirtualizing = "True"
    VirtualizingStackPanel.VirtualizationMode = "Recycling" />

To make it work for TreeView see this SO post: (I would not copy/paste XAML) VirtualizingStackPanel on a Treeview ist not Virtualizing

辅助性MSDN联系:





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签