public partial class CustomContentDialog : ContentDialog
{
protected override void OnApplyTemplate()
{
base.OnApplyTemplate();
if (this.FindDescendant<Grid>(x => x.Name == "CommandSpace") is Grid commandSpace)
{
HyperlinkButton cancel = new()
{
NavigateUri = new Uri("https://www.google.com"),
Content = "Cancel",
};
commandSpace.Children.Insert(0, cancel);
}
}
}
使用它:
var dialog = new CustomContentDialog
{
Title = "Title",
Content = "Content",
CloseButtonText = "Close",
XamlRoot = this.XamlRoot,
};
await dialog.ShowAsync();