Bryan Batts

Bryan Batts

  • NA
  • 7
  • 511

Comunicating Between ViewModels

Aug 17 2016 1:20 PM
Hello. 
 
I have a main ViewModel that loads two seperate child viewmodels. like so:
 
  1. /// <summary>  
  2.        /// Used to load edit/list user ViewModels.  
  3.        /// </summary>  
  4.        public MVVM.ViewModelBase ViewModel  
  5.        {  
  6.            get { return viewModel; }  
  7.            set  
  8.            {  
  9.                viewModel = value;  
  10.                RaisePropertyChanged("ViewModel");  
  11.            }  
  12.        }  
  13.        MVVM.ViewModelBase viewModel;  
  14.   
  15.        public UsersViewModel()  
  16.        {  
  17.            this.ViewModel = new UsersListViewModel();  
  18.        }  
  19.   
  20.        /// <summary>  
  21.        /// Adds a new user  
  22.        /// </summary>  
  23.        void addUserExecute()  
  24.        {              
  25.            ViewModel = new UsersEditViewModel(-1);  
  26.        }  
  27.        bool canAddUserExecute()  
  28.        {  
  29.            return true;  
  30.        }  
  31.        public ICommand AddUser { get { return new MVVM.RelayCommand(addUserExecute, canAddUserExecute); } } 
 I can't seem to figure out how to let my child (UsersEditViewModel) to tell the parent that i'm done editing and need to close/dispose.
 
Any help would be greatly appreciated.
 
 
 

Answers (2)