Reputation: 11
i am developing an application that supposed to have a lot of graphical capabilities, i am building an applicative layer using wpf. I want to build the applicative layer in a mvvm structure.
I am building above a single large wpf control which responsible for the graphic processing. Because this i started building a single view model responsible for the control, this view model grew large so does the xaml containing the graphic control due to massive use of commands, bindings and behaviors.
I would like to split the view model into several view models responsible for various aspects of the graphic control. How can i split the xaml into views for each view model, each responsible for his own bindings, behaviors, triggers etc for the same control?
Upvotes: 1
Views: 241
Reputation: 7486
There are several ways to do that also depending on your ViewModels implementations.
The first think that comes to my mind, you can give different DataContext to different controls, so you can do something like this (pseudo XAML):
<Window>
<Grid DataContext="ViewModel1">
<!-- xaml for that view model 1 -->
</Grid>
<Grid DataContext="ViewModel2">
<!-- xaml for that view model 2 -->
</Grid>
<Grid DataContext="ViewModel3">
<!-- xaml for that view model 3 -->
</Grid>
</Window>
Upvotes: 1