May 31

Written by: Soul Solutions
Sunday, 31 May 2009 

I’ve been using ListBoxes with IsSynchronizedWithCurrentItem property set to True to do a lot of master/detail views recently.  When using MVVM with Command Pattern it’s wasn’t immediately obvious to me how to manipulate which item was selected when I added/removed etc from the list.

If I’ve just created a client record and added it to my ObservableCollection of Clients in my viewModel I can use CollectionViewSource to get a hold of the view and manipulate the current item e.g.

CollectionViewSource.GetDefaultView(viewModel.Clients).MoveCurrentTo(client);
Technorati Tags: ,

Tags:

Your name:
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment   Cancel 
Copyright © 2002-2009 Soul Solutions Pty Ltd. | Login