Reputation: 123
I need to display a MessageDialog to the user if certain fields in the view are blank when they click a button to navigate. I can handle the input field validation from the view model just fine, I'm just not sure how to invoke a messagedialgo.showasync method from the view model and have it display on the view. Any suggestions?
Upvotes: 1
Views: 1007
Reputation: 15296
I saw the sample and lib source of Caliburn.Micro. IWindowManager
interface is only for WPF and Silverlight. For WinRT the sample contains this helper class.
using System;
using Windows.UI.Popups;
namespace Caliburn.Micro.WinRT.Sample.Results
{
public class MessageDialogResult : ResultBase
{
private readonly string _content;
private readonly string _title;
public MessageDialogResult(string content, string title)
{
_content = content;
_title = title;
}
public async override void Execute(ActionExecutionContext context)
{
var dialog = new MessageDialog(_content, _title);
await dialog.ShowAsync();
OnCompleted();
}
}
}
It can be called from viewmodel like this
new MessageDialogResult("content", "title");
See the code at CodePlex
Upvotes: 1