Property
Name
Title
Content
PrimaryButtonText
SecondaryButtonText
CloseButtonText
TitleTemplate
ContentTemplate
ContentTemplateSelector
DefaultButton
IsPrimaryButtonEnabled
IsSecondaryButtonEnabled
PrimaryButtonStyle
SecondaryButtonStyle
CloseButtonStyle
Underlay
UnderlaySystemBackdrop
WindowTitle
SystemBackdrop
IsResizable
HasTitleBar
CenterInParent
OwnerWindow
Foreground
Background
BorderBrush
BorderThickness
FlowDirection
RequestedTheme
Events
Name
PrimaryButtonClick
SecondaryButtonClick
CloseButtonClick
Methods
Example 1 2 3 4 5 6 7 8 9 10 11 12 WindowedContentDialog dialog = new () { Title = "YourTitle" , Content = "YourContent" , PrimaryButtonText = "YourPrimaryButtonText" , SecondaryButtonText = "YourSecondaryButtonText" , CloseButtonText = "YourCloseButtonText" , DefaultButton = ContentDialogButton.Primary, OwnerWindow = App.Current.MainWindow }; ContentDialogResult result = await dialog.ShowAsync(); var result = result.ToString();
If you want to prevent dialog from closing after buttons clicked, please handle click event and set e.Cancel = true where e is ContentDialogWindowButtonClickEventArgs.
dialog.PrimaryButtonClick += (o, e) => e.Cancel = true;
If you want to show a Underlay (SmokeLayer or SystemBackdrop), you should specify an OwnerWindow
.
Using in XAML / WindowedContentDialog 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 <Page.Resources > <dev:WindowedContentDialog x:Key ="XamlWindowedContentDialog" x:Name ="XamlWindowedContentDialog" CloseButtonText ="CloseButtonText" DefaultButton ="Primary" IsModal ="false" IsPrimaryButtonEnabled ="true" IsSecondaryButtonEnabled ="true" PrimaryButtonText ="PrimaryButtonText" SecondaryButtonText ="SecondaryButtonText" > <dev:WindowedContentDialog.SystemBackdrop > <MicaBackdrop /> </dev:WindowedContentDialog.SystemBackdrop > <dev:WindowedContentDialog.Title > <dev:MessageBoxHeader Icon ="Information" Text ="Title" /> </dev:WindowedContentDialog.Title > <StackPanel > </StackPanel > </dev:WindowedContentDialog > </Page.Resources >
1 ContentDialogResult result = await XamlWindowedContentDialog.ShowAsync();
Using in XAML / ContentDialogWindow 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 <dev:ContentDialogWindow x:Class ="Sample.SampleContentDialogWindow" xmlns ="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x ="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d ="http://schemas.microsoft.com/expression/blend/2008" xmlns:dev ="using:DevWinUI" xmlns:mc ="http://schemas.openxmlformats.org/markup-compatibility/2006" Title ="Sample ContentDialogWindow" CloseButtonText ="Close Button" DefaultButton ="Primary" DialogTitle ="Title" PrimaryButtonText ="Primary Button" SecondaryButtonText ="Secondary Button" mc:Ignorable ="d" > <dev:ContentDialogWindow.SystemBackdrop > <MicaBackdrop /> </dev:ContentDialogWindow.SystemBackdrop > <StackPanel > </StackPanel > </dev:ContentDialogWindow >
1 new SampleContentDialogWindow().OpenAfterLoaded();
Demo you can run demo and see this feature.