Exemple #1
0
 public AlertSheet(string title, string message, string primaryButtonText, string[] additionalButtons, AlertSheetStyle style) : base(style)
 {
     _additionalButtons = additionalButtons;
     _primaryButtonText = primaryButtonText;
     _message           = message;
     _title             = title;
     this.style         = style;
 }
        public static Task <int> ShowAlert(AbsoluteLayout targetContainer, string title, string body, string primaryButtonTitle = "Okay", string[] additionalButtons = null, AlertSheetStyle style = null)
        {
            style = style ?? AlertSheetStyle.Default;

            additionalButtons = additionalButtons ?? new string[0];

            var tcs = new TaskCompletionSource <int>();

            var alertView = new AlertSheet(title, body, primaryButtonTitle, additionalButtons, style);

            targetContainer.Children.Add(alertView, new Rectangle(0, 0, 1, 1), AbsoluteLayoutFlags.All);
            alertView.Show();
            alertView.ButtonTapped += (sender, e) => tcs.TrySetResult((e as AlertSheetEventArgs).ButtonIndex);

            return(tcs.Task);
        }