wpf - Change data context when using UserControls -


i'm using simple main window contains 2 custom user controls (that i've created) user controls has modelview code file each (im using mvvm pattern). each modelview file contains single command (and command implementation of execute , canexecute). problem when need active each command (through mainwindow cause main window holds custom user controls) need change datacontext of main window viewmodel of control in focus otherwisw cant execute command (the command binding inside usercontrol.xaml cant find command). think tracking after focused usercontrol in order change mainwindow datacontext not way. faced kind of problem before ??

thanks.

a way of solving creating viewmodel main window , add 2 properties vm, 1 each viewmodel created before.

this way can assign new vm datacontext of window , bind datacontext of each user control 1 of properties.

put commands on correct vm want use it. make sense?

btw: call modelview i'd call viewmodel.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -