WPF - Dialogs Using MVVM

When using custom dialog boxes in an MVVM application, do you find it convenient to use code to handle properties, events, etc.? Or do I always need the ViewModel to bind to each dialog box? What do you think?

+4
source share
4 answers

By what criteria should we decide whether the code is OK or not?

What if the user dialog is a complex wizard? What if the dialog box is a complete gadget? In those cases, I think we can argue that MVVM is worth it, and the code is really not very attractive.

If we accept this, then where do we draw the line? I think we should not, because a dialogue that is simple today may become difficult in the future . It would be better to stay consistent.

In other words: MVVM completely

See also this related question: MVVMs and commands that show more GUI

+1
source

The reasons for having a ViewModel in a dialog box are almost the same as for having them in any other type of window, as far as I know, so I would do the same (whatever that is!), Personally, I would have a ViewModel and as little as possible in the code.

+1
source

Dialogue is just another view. The main purpose of ViewModel is to encapsulate the behavior of a view. In my opinion, if this opinion has behavior, then, in my opinion, the ViewModel is justified. If this is a static user interface or simply attached directly to a model element without any encoded behavior than not, a ViewModel is not required.

+1
source

Why not use ViewModel for dialogue?

ViewModel WPF Application Framework (WAF) sample application shows how to use WPF dialogs with ViewModels.

0
source

Source: https://habr.com/ru/post/1316296/


All Articles