2

I've used ICollectionView a few times and never had any problems... but I can't get this one to work.

In my constructor I do the following:

    _viewModels = new ObservableCollection<MyViewModel>();

    var icv = CollectionViewSource.GetDefaultView(_viewModels);
    MyCollectionView = icv; 

The one thing that I think is different is that I populate my _viewModels with a separate call. So with a button for example after the app loads. Even if I call MyCollectionView.Refresh() though at that time, and _viewModels has objects in it, MyCollectionView is still empty.

Should this work? If so what am I missing and what can I look for?

4

1 回答 1

0

似乎 Refresh 在 .Net 4.5 中没有任何作用,我没有在 4 上尝试过,所以我不能确定它什么时候停止工作,如果有的话。我喜欢做的是:

     public ICollectionView MyCollectionView
     {
        get 
        {              
            return new CollectionView(SourceCollection); 
        }
     }
于 2014-12-23T20:22:49.547 回答