Closing. Yes it

I like the idea of ​​MVVM, but really struggles with the hoop required for really basic things like getting a value from a modal dialog or closing a window. I mean...

App.xaml

defines StartupUri=MainWindow.xaml

.

MainWindow.xaml

defines DataContext=MainWindowViewModel

.

Like MVVM, the View knows about the ViewModel, but NOT the other way around.

I can't seem to find a (normal? Logical? Simple?) Way to intercept the close event. I can use smart blocks of code like MVVMLight .. but I always get either handling the event (messy) or not being able to completely stop the closure or skip it.

I refuse to believe it is so difficult - it must be I am falling into another false lie. Please put me straight!

Thanks again for your time and patience - it is really appreciated.

+3


source to share


2 answers


This is easily handled through attached properties or behavior. I wrote a sample in the Expression gallery that shows how you can use a Behavior to bind this processing to a command in your virtual machine without using code.



+3


source


Caliburn.Micro framework manages dialogs and closes windows very elegantly in my opinion



0


source







All Articles