Created
May 3, 2018 06:33
-
-
Save pavlovmilen/46fbd6e4be69673d5efa975f07c4c658 to your computer and use it in GitHub Desktop.
Show alert on UI XF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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