Refresh combobox list from other window, MVVM

前端 未结 6 1945
长情又很酷
长情又很酷 2021-01-21 10:53

I\'m working on some application and I have one problem. I have two windows (Bookings - parent and Guests - child). In the parent window, I have one combo box with list of guest

6条回答
  •  無奈伤痛
    2021-01-21 11:14

    If your creating your child window from your main window as well as your child view model, you could either look at your window closed event or if you need to know before the window gets closed you could also subscribe to the property changed event of the child window when it is created an when a property changes on the child view model you can check to see if its the property you want. If so update your list.

    ChildViewModel n = new ChildViewModel()
    n.PropertyChanged += new PropertyChangedEventHandler(n_PropertyChanged);
    void n_PropertyChanged(object sender, PropertyChangedEventArgs e)
    { if(e.PropertyName == "myChangingObject")
    //reload list
    }
    

提交回复
热议问题