Skip to content

Instantly share code, notes, and snippets.

@pavlovmilen
Created May 3, 2018 06:33
Show Gist options
  • Save pavlovmilen/46fbd6e4be69673d5efa975f07c4c658 to your computer and use it in GitHub Desktop.
Save pavlovmilen/46fbd6e4be69673d5efa975f07c4c658 to your computer and use it in GitHub Desktop.
Show alert on UI XF
public static class PageExtensions
{
public static Task<bool> DisplayAlertOnUi(this Page source, string title, string message, string accept, string cancel)
{
TaskCompletionSource<bool> doneSource = new TaskCompletionSource<bool>();
Device.BeginInvokeOnMainThread(async () =>
{
try
{
var result = await source.DisplayAlert(title, message, accept, cancel);
doneSource.SetResult(result);
}
catch (Exception ex)
{
doneSource.SetException(ex);
}
});
return doneSource.Task;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment