J4N
J4N

Reputation: 20707

WPF-MVVM: Display a modal windows from the viewModel

I'm (still) learning MVVM through a small project, and I've one question:

I've a button on my windows, this button start a command on the ViewModel. The viewModel has to use a "OpenFileDialog" to known which file has to be opened. I'm using Unity for the DI.

The problem is that I should give a "Windows" in parameter to ensure that the open file dialog is modal(the user cannot use the interface when the openFile is opened).

But in the viewModel, I don't have access to the "Windows" object, so what is the correct approach?

Thank you!

Upvotes: 0

Views: 358

Answers (1)

Arsen Mkrtchyan
Arsen Mkrtchyan

Reputation: 50712

just pass bool to interface method that indicates if window is modal or not, and open modal or not modal dialog in view side depending to that variable

Upvotes: 2

Related Questions