Implementing “close window” command with MVVM

后端 未结 12 1698
既然无缘
既然无缘 2020-12-05 09:31

So my first attempt did everything out of the code behind, and now I\'m trying to refactor my code to use the MVVM pattern, following the guidance of the MVVM in the box inf

12条回答
  •  鱼传尺愫
    2020-12-05 10:14

    Given a way, Please check

    https://stackoverflow.com/a/30546407/3659387

    Short Description

    1. Derive your ViewModel from INotifyPropertyChanged
    2. Create a observable property CloseDialog in ViewModel, Change CloseDialog property whenever you want to close the dialog.
    3. Attach a Handler in View for this property change
    4. Now you are almost done. In the event handler make DialogResult = true

提交回复
热议问题