Click here to Skip to main content
15,883,901 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: Silverlight / WPF Every page a content control Pin
Abhinav S27-May-11 8:15
Abhinav S27-May-11 8:15 
AnswerRe: Silverlight / WPF Every page a content control Pin
DL00131-May-11 2:58
DL00131-May-11 2:58 
GeneralRe: Silverlight / WPF Every page a content control Pin
Pete O'Hanlon31-May-11 3:26
mvePete O'Hanlon31-May-11 3:26 
QuestionSTYLUS POINT -ELLİPS Pin
mustafayilmaz5627-May-11 3:34
mustafayilmaz5627-May-11 3:34 
QuestionHow to pass a new instance of a viewmodel to an existing usercontrol? Pin
Duke Carey26-May-11 15:08
professionalDuke Carey26-May-11 15:08 
AnswerRe: How to pass a new instance of a viewmodel to an existing usercontrol? Pin
Pete O'Hanlon26-May-11 22:08
mvePete O'Hanlon26-May-11 22:08 
GeneralRe: How to pass a new instance of a viewmodel to an existing usercontrol? Pin
Duke Carey27-May-11 0:42
professionalDuke Carey27-May-11 0:42 
GeneralRe: How to pass a new instance of a viewmodel to an existing usercontrol? Pin
Pete O'Hanlon27-May-11 2:01
mvePete O'Hanlon27-May-11 2:01 
A simple mechanism to achieve this is to have the parent level VM manage the population of the data in a model. As long as the child can see the data in the same instance of the model, then it can retrieve and manage it's own ObservableCollection based on this data. All you would need to do would be to hook into the CollectionChanged event on the model to know that you had to retrieve the new data items (although I would normally look at using a more explicit event because the CollectionChanged gets raised on every change to the collection, and you might want to wait for the data to be updated completely before you react to the change).

A mechanism such as making the model class static would ensure that all VMs could see the same instance, and react to changes in it.

So, why am I recommending this approach rather than binding to the VM? After all, you could achieve a similar effect that way. By going with this approach, I've looked at completely decoupling the VMs - ensuring that they don't need to know about each other and, more importantly, ensuring that issues such as you have faced here are, to a large extent, minimised as you change the VMs. Remember, the VM matches what's in the View, so you don't want to have to rejig things around again just because you move something from one view to another.

Forgive your enemies - it messes with their heads


My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility


GeneralRe: How to pass a new instance of a viewmodel to an existing usercontrol? Pin
Mycroft Holmes27-May-11 13:54
professionalMycroft Holmes27-May-11 13:54 
GeneralRe: How to pass a new instance of a viewmodel to an existing usercontrol? Pin
Duke Carey31-May-11 0:37
professionalDuke Carey31-May-11 0:37 
GeneralRe: How to pass a new instance of a viewmodel to an existing usercontrol? Pin
Mycroft Holmes31-May-11 13:10
professionalMycroft Holmes31-May-11 13:10 
GeneralRe: How to pass a new instance of a viewmodel to an existing usercontrol? Pin
_Maxxx_31-May-11 13:32
professional_Maxxx_31-May-11 13:32 
GeneralRe: How to pass a new instance of a viewmodel to an existing usercontrol? Pin
Pete O'Hanlon31-May-11 21:37
mvePete O'Hanlon31-May-11 21:37 
GeneralRe: How to pass a new instance of a viewmodel to an existing usercontrol? Pin
_Maxxx_29-May-11 15:35
professional_Maxxx_29-May-11 15:35 
GeneralRe: How to pass a new instance of a viewmodel to an existing usercontrol? Pin
Pete O'Hanlon30-May-11 23:05
mvePete O'Hanlon30-May-11 23:05 
GeneralRe: How to pass a new instance of a viewmodel to an existing usercontrol? Pin
_Maxxx_31-May-11 13:16
professional_Maxxx_31-May-11 13:16 
GeneralRe: How to pass a new instance of a viewmodel to an existing usercontrol? Pin
Pete O'Hanlon31-May-11 21:37
mvePete O'Hanlon31-May-11 21:37 
GeneralRe: How to pass a new instance of a viewmodel to an existing usercontrol? Pin
Mycroft Holmes31-May-11 13:14
professionalMycroft Holmes31-May-11 13:14 
GeneralRe: How to pass a new instance of a viewmodel to an existing usercontrol? Pin
_Maxxx_31-May-11 13:27
professional_Maxxx_31-May-11 13:27 
GeneralRe: How to pass a new instance of a viewmodel to an existing usercontrol? Pin
Mycroft Holmes31-May-11 14:30
professionalMycroft Holmes31-May-11 14:30 
GeneralRe: How to pass a new instance of a viewmodel to an existing usercontrol? Pin
_Maxxx_31-May-11 15:59
professional_Maxxx_31-May-11 15:59 
QuestionHow to Convert Byte Array to BitmapSource in C# for Silverlight Pin
Vimalsoft(Pty) Ltd26-May-11 0:18
professionalVimalsoft(Pty) Ltd26-May-11 0:18 
QuestionRe: How to Convert Byte Array to BitmapSource in C# for Silverlight Pin
Mark Salsbery26-May-11 11:10
Mark Salsbery26-May-11 11:10 
AnswerRe: How to Convert Byte Array to BitmapSource in C# for Silverlight Pin
Vimalsoft(Pty) Ltd26-May-11 11:13
professionalVimalsoft(Pty) Ltd26-May-11 11:13 
GeneralRe: How to Convert Byte Array to BitmapSource in C# for Silverlight Pin
Mark Salsbery26-May-11 11:39
Mark Salsbery26-May-11 11:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.