Reputation: 16793
I am using the Acr.Dialogs
as follows, to display dialog box.
However, it seems it only supports one button which is OK
. However, I want to have Cancel
and OK
buttons.
ViewModel.cs
var alertConfig = new AlertConfig
{
Message = "Are you sure?",
OnOk = () => {
NotifyUpdated();
},
};
Mvx.Resolve<IUserDialogs>().Alert(alertConfig);
Upvotes: 2
Views: 645
Reputation: 3888
Confirmation dialogs have OK and Cancel by default. You could use Task<bool> IUserDialogs.ConfirmAsync(string message, string title = null, string okText = null, string cancelText = null, CancellationToken? cancellationToken)
method instead.
var confirm = await Mvx.Resolve<IUserDialogs>().ConfirmAsync("Are you sure?");
if (confirm)
{
NotifyUpdated();
}
else
{
// User pressed Cancel
}
If you want to keep things synchronous you could use this code:
Mvx.Resolve<IUserDialogs>().Confirm(new ConfirmConfig
{
OnAction = b =>
{
if (b)
{
NotifyUpdated();
}
else
{
// User pressed Cancel
}
}
});
Upvotes: 2