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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -