我正在使用 ContentDialog 來顯示各種內容(進度條、狀態文本),并且我想給它與使用 MesasgeDialog 相同的默認外觀以使其更適合。
MessageDialog 的默認布局和樣式是否有 XAML 代碼?或者有人可以告訴我使用的是什么字體嗎?
任何適合默認 MessageDialog 美學的東西都會有所幫助。

^我想要在 ContentDialog 上的示例 MessageDialog 樣式。
使用 XAML 的答案將是理想的。
uj5u.com熱心網友回復:
ContentDialog您可以為此場景創建自定義控制元件。然后你可以改變ContentDialog.
的最大寬度有一個默認值ContentDialog,因此您需要先覆寫ContentDialogMaxWidthApp.Xaml 中的值。
像這樣:
<Application.Resources>
<x:Double x:Key="ContentDialogMaxWidth">2000</x:Double>
</Application.Resources>
之后,您可以右鍵單擊您的專案,選擇Add->New Item->ContentDialog以創建自定義控制元件ContentDialog。
稍微改變一下樣式,讓它看起來像一個 MessageDialog。這是代碼:
<ContentDialog
x:Class="TestContentDialog.MContentDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:TestContentDialog"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="Please Wait">
// you could try to change the style to meet your own requirement.
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Width="800" Height="150" >
<Grid.RowDefinitions>
<RowDefinition Height="48"/>
<RowDefinition Height="*"/>
<RowDefinition Height="48"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20"/>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" Text="Please Wait" FontSize="28"/>
<TextBlock Grid.Column="1" Grid.Row="1" FontSize="18" Text="Still checking for updates" />
<Button Grid.Row="2" Grid.Column="1" Width="100" Height="30" Content="Close" Click="Button_Click" Margin="650,0,0,0" />
</Grid>
代碼隱藏:
public sealed partial class MContentDialog : ContentDialog
{
public MContentDialog()
{
this.InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
this.Hide();
}
}
在主頁上使用它:
<Grid>
<Button Content="Click" Click="Button_Click"/>
<local:MContentDialog x:Name="MContentDialog" CornerRadius="8"/>
</Grid>
private async void Button_Click(object sender, RoutedEventArgs e)
{
await MContentDialog.ShowAsync();
}
結果如下所示:

轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/506312.html
