mrfangzheng

Hope and fear are useless. Be confident, and always be prepared for the worst.
  首页  :: 新随笔  :: 联系 :: 管理

WPF : 对Collection要注意重用子控件

Posted on 2009-11-24 15:36  mrfangzheng  阅读(256)  评论(0编辑  收藏  举报

一般的,

ListBox.ItemSource <==> ObservableCollection<User>

如果经常更新数据源的话, 会引起子控件不断的创建和销毁, 从而引起性能问题.

一个办法是:

ListBox.ItemSource <==> ObservableCollection<UserProxy> <==> ObservableCollection<User>

通过UserProxy是否有真实值来决定是否显示子控件(子控件不销毁)