Вопрос

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