【问题标题】:CollectionView.MoveCurrentTo sets Current item to nullCollectionView.MoveCurrentTo 将当前项目设置为 null
【发布时间】:2013-11-27 13:50:16
【问题描述】:

我正在尝试使用 MoveCurrentTo 方法在 CollectionView 中设置当前项,但结果是 collectionView:s 当前项设置为 null。

我的 collectionViewSource.source 是一本字典。我想要做的是将一个新项目添加到我的集合中,然后将视图中的当前项目设置为新项目,但我无法让它工作。

谁能解释为什么这不起作用?

 Customers customers = null;

  customers = new Customers();
  customers.Fill();

  CustomerCollectionView = new CollectionViewSource();
  CustomerCollectionView.Source = customers.Values;

  Customer customerItem = new Customer();
  customers.Add(customerItem);
  CustomerCollectionView.View.MoveCurrentTo(customerItem);

【问题讨论】:

    标签: c# collectionview


    【解决方案1】:

    customers.Values 公开的集合可能不支持 INotifyCollectionChanged。使用 ObservableDictionary 实现可能会解决您的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-28
      • 2017-02-21
      • 2014-09-12
      • 1970-01-01
      相关资源
      最近更新 更多