I'm building a WPF MVVM application and I'd like to keep what I can conforming to MVVM (I know some stuff is over-engineering, putting a best effort here though).
I've run into a small dillema, I need to Hide / Close a window based on some logic in one the the methods in the view model.
I can't for the life of me come up with a reliable way to do it. I've bound a Visibility
property to the window's Visibility DP, which works (sorta) but how would I call Close()
on the dialog?
I'm using View-First MVVM so the view model has no knowledge of the view, the view instantiates a view-model (through DI/IoC) and sets it as the DataContext.
Commands work the wrong way, events are out of the question unless I bind to it in code behind which is something id rather not do if there's an MVVM way to do it that isn't entirely convoluted.
Any ideas from the greater SO community?
Or maybe I'm missing something about MVVM in general? Either way, let me know :o