I am trying to display a dialog with ok and cancel button on a button click. And depending on the dialog result I would like to save\cancel the operation in wpf. I am not sure how to show a dialog in wpf. Any help?

有帮助吗?

其他提示

You don't use MVVM to do that. Using the MVVM pattern does not mean to never use events and codebehind.

In my opinion, the best healthy mix using the MVVM pattern is to use bindings and commands and other "MVVM-stuff" in the XAML, but also events and code. If it has to do with the UI strictly (like a messagebox or double click or thread handling), use code the old-fashion way.

So use the MessageBox.Show("hello"); in the codebehind as usual, because it is UI related and has less meaning to the model/logic. The same goes with OpenFileDialog and other dialogs.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top