2013-11-27 106 views
0

我想使用MoveCurrentTo方法設置CollectionView中的當前項目,但結果是collectionView:s當前項目設置爲null。CollectionView.MoveCurrentTo將當前項目設置爲空

我的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); 

回答

0

由客戶公開​​的集合。值可能不支持INotifyCollectionChanged。使用ObservableDictionary實現可能會解決您的問題。

相關問題