I am using Prism 6.1 to implement the MVVM pattern. For notification/confirmation dialogues I am using InteractionRequest and InteractionRequest as detailed on the Advanced MVVM Scenarios Using the Prism Library page on msdn. My question is how can I start using OpenFileDialog within MVVM. Prism doesn't provide something similar for Save and Open dialogues. Can you please give me an example of the code that should be incorporated in the View & ViewModel. Thank you.
YOU need to simply create a dialog service.
public interface IDialogService
{
void Show();
}
public class DialogService : IDialogService
{
public void Show()
{
//logic to show your dialogs
}
}
Make sure to register it with your container:
Conatiner.Register<IDialogService, DialogService>( do you want a singletone?);
Then ask for it in your ctor
public ViewAViewModel(IDialogService ds) { ... }
Now call it whenever you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With