Ejemplo n.º 1
0
        public static Task <ContentDialogResult> ShowContentAsync(object content, string title      = null,
                                                                  string closeButtonText            = "Close", string primaryButtonText = null, string secondaryButtonText = null,
                                                                  ContentDialogButton?defaultButton = null)
        {
            ContentDialogButton button;

            if (defaultButton.HasValue)
            {
                button = defaultButton.Value;
            }
            else if (!string.IsNullOrWhiteSpace(primaryButtonText))
            {
                button = ContentDialogButton.Primary;
            }
            else if (!string.IsNullOrWhiteSpace(secondaryButtonText))
            {
                button = ContentDialogButton.Secondary;
            }
            else
            {
                button = ContentDialogButton.Close;
            }

            ContentDialog dialog = new ContentDialog()
            {
                Content       = content,
                DefaultButton = button,
            };

            if (!string.IsNullOrWhiteSpace(title))
            {
                dialog.Title = title;
            }
            if (!string.IsNullOrWhiteSpace(primaryButtonText))
            {
                dialog.PrimaryButtonText      = primaryButtonText;
                dialog.IsPrimaryButtonEnabled = true;
            }
            if (!string.IsNullOrWhiteSpace(secondaryButtonText))
            {
                dialog.SecondaryButtonText      = secondaryButtonText;
                dialog.IsSecondaryButtonEnabled = true;
            }
            if (!string.IsNullOrWhiteSpace(closeButtonText))
            {
                dialog.CloseButtonText = closeButtonText;
            }

            return(dialog.ShowSafeAsync());
        }