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

WPF

 
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 
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 
_Maxxx_ wrote:
I don't understand why you say this?
 
Lets say I will have a page
showing a list of customers, and also the individual fields from the currently
selected customer.
 
In MVVM I would create a VM for the page, and
also (because the functionality is self-contained) a VM for the list of
customers and a VM for the individual Customer fields (that is, ONE VM with
properties for each Customer field)
 
Now, my Page VM is nonsense
without having a CustomerListVM and a CustomerEditVM somehow contained within
it.
 
It certainly doesn't know about the VIEWs but it MUST know
about the ViewModels
 
Similarly neither the customerListVM nor the
CustomerEditVM can know about the PageVM - they need to exist
independently.
 
so surely my PageVM legitimately can say "I want to
display this list of customers" - and give the list to the CustomerListVM?


If you check out the problem that the user describes, it's not the same issue that you are describing here. What you describe is a perfectly acceptable solution where you have one view containing data derived from several VMs, where the containing VM is still being displayed.

What the OP described however was a different scenario. He has moved the implementation out of a single view into multiple views, and there is no real physical interaction between these views other than the fact that they were all originally part of one larger VM. The key point here is that the view/viewmodel interaction here is no longer with the "parent" VM, it's with the child VM. This means that, conceptually, the new VM can exist without knowledge of the old VM. The Model part, which has been entirely forgotten about in this situation, can be the same model (and is the one I would choose). So, rather than having to contort the code to worry about maintaining this disconnected list of VMs, it makes more sense to just have the child VM use the same model. Remember that a lot of people mistake the model for always being the data layer; it doesn't have to be, so a simple containing model makes this scenario a whole lot easier.

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
_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 
GeneralRe: How to Convert Byte Array to BitmapSource in C# for Silverlight Pin
Vimalsoft(Pty) Ltd26-May-11 19:04
professionalVimalsoft(Pty) Ltd26-May-11 19:04 
GeneralRe: How to Convert Byte Array to BitmapSource in C# for Silverlight Pin
Mark Salsbery26-May-11 19:09
Mark Salsbery26-May-11 19:09 
QuestionHow to retrieve hyperlink url from selection text in wpf? Pin
John-ph25-May-11 23:06
John-ph25-May-11 23:06 
QuestionInstaller for WPF Control Pin
Prasoon Chaudhary25-May-11 21:22
Prasoon Chaudhary25-May-11 21:22 
AnswerRe: Installer for WPF Control Pin
Wayne Gaylard25-May-11 21:32
professionalWayne Gaylard25-May-11 21:32 
QuestionRe: Installer for WPF Control Pin
Prasoon Chaudhary25-May-11 22:09
Prasoon Chaudhary25-May-11 22:09 
AnswerRe: Installer for WPF Control Pin
Abhinav S26-May-11 7:55
Abhinav S26-May-11 7:55 

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.