I've created my first MVVMLight project, and I've a question:
I've a button, on which is bound a command. When the command execute, in different use cases, I've to get/give information to the enduser, like:
- Ask where the project should be saved if the project is new
- Give a confirmation that everything has been correctly saved
I know that I can do a MessageBox.Show
/... but where? Because in regards of the separation of concerns I guess it should be in the ViewModel? So what is the mecanism in place that I should use for this?
My ViewModel is basically like this:
public class MainViewModel : BaseViewModel
{
private static readonly Logger m_logger = LoggerProvider.GetLogger("MyPath.MainViewModel");
private ISerializationService m_serializationService;
public ICommand TrySaveCommand { get; set; }
//Lot of other fields here
public MainViewModel()
{
m_serializationService = ServiceLocator.Current.GetInstance<ISerializationService>();
TrySaveCommand = new RelayCommand(TrySave);
}
private void TrySave()
{
DispatcherHelper.RunAsync(() =>
{
//Here I need to get the path where I save on some condition
m_serializationService.SaveProject(pathIGotFromTheUser);
//Give a feedback that everything has been correctly saved(for test purpose, a MessageBox.Show() )
});
}
}
So how should I do to get information from the user on the file to save? (with SaveFileDialog
) and display that it has correctly been saved (with MessageBox.Show
)
Thank you