static void Main(string[] args) { MainViewModel mainViewModel = new MainViewModel(); Child1ViewModel child1 = new Child1ViewModel(); Child2ViewModel child2 = new Child2ViewModel(); mainViewModel.UpdateName("Name1"); Console.WriteLine(child1.Name); Console.WriteLine(child2.Name); Console.ReadKey(); }
public void MyAction(object obj) { if (obj == null) { return; } //if CommandParameter is Cild1VM if (obj.ToString() == "Child1VM") { CurrentViewModel = new Child1ViewModel(); } //if CommandParameter is Cild1VM else if (obj.ToString() == "Child2VM") { CurrentViewModel = new Child2ViewModel(); } }
public MainViewModel(Child1ViewModel child1, Child2ViewModel child2, DiagnosticsViewModel diagnosticsViewModel) { Diagnostics = diagnosticsViewModel; Child1 = child1; Child2 = child2; }
public MainViewModel() { Child1ViewModel = new Child1ViewModel(this); // inject parent view model to child view model //Child2ViewModel = new Child2ViewModel(this); }