Reputation: 562
I am migrating/rewriting a SL4 project using the MVVM pattern. The trouble I'm having is that I have some user controls that interact only with other user controls(no connection to the Model). Where to I implement the code behind functions for this controls?
Upvotes: 0
Views: 523
Reputation: 9153
There are several options. If the controls have a natural hierarchy (such as one is the other's parent) consider wrapping them into a user control and leveraging RoutedEvents.
If they are sibling controls and there is a natural parent for them, group them into a parental user control and create a viewmodel for that control that handles interaction.
If the controls are in totally separate areas on the UI, consider using EventAggregator to have the controls fire and respond to each others messages.
Upvotes: 2
Reputation: 5691
if you are using mvvm pattern just use behaviours insteed of writing the code in the code behind files. start learning behaviours
http://www.nikhilk.net/Silverlight-Behaviors.aspx http://wildermuth.com/2009/05/16/Writing_Behaviors_for_Silverlight_3_-_Part_1 http://joel.neubeck.net/2009/07/silverlight-3-drag-behavior/
Upvotes: 0