I've been evaluating a number of frameworks and just as I was about to commit to MVVM Light I stumbled upon Simple MVVM. While I have not dug into the framework yet (in the process right now) I had a question regarding Simple MVVM as it my address one of
my specific project needs. Within my silverlight application I have a number of custom user controls which all inheritted their base data context from their parent view (See pseudo diagram below)
- usercontrol A (listbox)
- usercontrol B (listbox templated Item)
- button within user control B
Where I have continually run into problems is in having events call commands from the view model. While I have used the blend interactivity.dll to handle the EventToCommand I find that I am forced to set the data context of the button to my view model within
the xaml. Doing this always instantiats a new VM which would blow out any parameters etc that I may be passing to the VM via INPC. I have a specific need to return a collection to listbox, which the user can then click to select a row. This selectionChange
event captured an id which would be passed to the vm via INPC. This id would then be used as a parameter that would be included in the command call back to the service to retrieve additional data.
MVVM Light provides a means to allow objects within a user control of retaining the data context of the parent object(View) vs. limiting it to just the context of the user control. While I have created binding helper classes to overcome this issue
I have found my approach to be a bit on the hacky side and not something that I feel comfortable placing in a production environment.
Can Simple MVVM help me overcome these obstacles or does Simple MVVM provide more elegant asolution to this type of interaction/process? If so, are there any existing samples or documents out that I can reference to build my own proof of concept