View instanciated 2 times with CollectionViewSource.GetDefaultView

178 Views Asked by At

I have a ViewModel that I want to display. I use the command:

    var CollectionView = CollectionViewSource.GetDefaultView (MyViewModel);
    if (CollectionView! = null)
        collectionView.MoveCurrentTo (MyViewModel);

The problem is that it create two instance of the view with the same instance of the ViewModel.

Someone has an idea of ​​my problem?

Thanks

1

There are 1 best solutions below

1
On

Your code doesn't really make sense... the parameter of CollectionViewSource.GetDefaultView is supposed to be some kind of collection, but you're passing a ViewModel. You should pass the collection that contains the ViewModel.