.net - Assigning property of ViewModel to property of another ViewModel in C# WPF desktop app -
.net - Assigning property of ViewModel to property of another ViewModel in C# WPF desktop app -
i'm developing c# wpf mvvm
app. i'm new to mvvm
, not using toolkits/libraries, actioncommand
class implements icommand
interface , baseinpc
class implements inotifypropertychanged
(my viewmodels derive class).
my model has dataset
class string inputpath
property (the location of dataset file).
in mainview
, have menu
on top view of it's own (menuview
), implemented using usercontrol
has it's datacontext
set it's corresponding menuviewmodel
. each menu item bound actioncommand
basic io operations, such openfiledialogs
loading files etc. menuviewmodel
has selectedpath
property holding location of file.
my problem this: when select file using menuview
(i.e. setting selectedpath
property in menuviewmodel
), want set dataset.inputpath
selectedpath
. dataset
class instantiated in mainviewmodel
, not menuviewmodel
, pretty much i'm stuck.
is approach correct? if so, how can dataset.inputpath
(in mainviewmodel
) set selectedpath
(of menuviewmodel
)?
if insist on not using mvvm framework need write own message bus implementation...
otherwise, virtually mvvm frameworks utilize message bus type of inter-vm communication picking nice noob friendly mvvm framework (i'd recommend simple mvvm toolkit or mvvm light) , utilizing message bus instead of reinventing wheel , writing own mb way go.
c# .net wpf mvvm
Comments
Post a Comment