c# - MVVM : Share data between ViewModels -
how share data between multiple viewmodels ?
for example there class named project in application .
public class project : modelbase { private string _projectname; public string projectname { { return _projectname; } set { _projectname = value; raisepropertychanged(() => projectname); } } }
in multiple viewmodels application should access activeproject.
what's best way share project between viewmodels ?
- mediator pattern ? (messaging)
- static object
- singleton pattern (if yes how?)
i've used messaging before needs codding . viewmodels i've create activeproject property , have register messenger update that.
use mvvm light framework.
code example appreciated.
i create viewmodel acts parent project viewmodels. (let's call solution)
the solution viewmodel have property activeproject , observable collection of projects.
Comments
Post a Comment