Вы можете создать элемент управления контентом и вызвать его в своем коде
<ContentDialog
x:Class="TestButton.MessageDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:TestButton"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="TITLE"
PrimaryButtonText="Button1"
SecondaryButtonText="Button2"
PrimaryButtonClick="ContentDialog_PrimaryButtonClick"
SecondaryButtonClick="ContentDialog_SecondaryButtonClick">
<Grid>
</Grid>
</ContentDialog>
Создать класс и вызвать элемент управления выше (как показано ниже), а затем вы можете обратиться к функции ниже для отображения диалогового окна.
public ContentDialogResult ShowMessage(string message, string primaryButtonText = "OK", string secondaryButtonText = "", bool isSecondaryButtonEnabled = false)
{
MessageDialog newDialog = new MessageDialog() { MaxHeight = 1000, MaxWidth = 1000 };
newDialog.Title = "";
newDialog.Content = message;
newDialog.IsSecondaryButtonEnabled = isSecondaryButtonEnabled;
newDialog.PrimaryButtonText = primaryButtonText;
newDialog.SecondaryButtonText = secondaryButtonText;
newDialog.HorizontalAlignment = left;
return newDialog.ShowAsync().GetResults();
}
Надеюсь, это поможет