Skip to content

Commit

Permalink
chore: add async box example
Browse files Browse the repository at this point in the history
  • Loading branch information
emako committed Aug 15, 2024
1 parent 3e0c8ba commit 23836e0
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/Wpf.Ui.Test/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,34 @@
CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}}"
Content="Error" />
</StackPanel>
<StackPanel Margin="0,8,0,0" Orientation="Horizontal">
<TextBlock
MinWidth="80"
VerticalAlignment="Center"
FontSize="14"
Foreground="{DynamicResource TextFillColorTertiaryBrush}"
Text="Async" />
<ui:Button
Margin="16,0,0,0"
Command="{Binding AsyncShowMessageBoxCommand}"
CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}}"
Content="Information" />
<ui:Button
Margin="16,0,0,0"
Command="{Binding AsyncShowMessageBoxCommand}"
CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}}"
Content="Warning" />
<ui:Button
Margin="16,0,0,0"
Command="{Binding AsyncShowMessageBoxCommand}"
CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}}"
Content="Question" />
<ui:Button
Margin="16,0,0,0"
Command="{Binding AsyncShowMessageBoxCommand}"
CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}}"
Content="Error" />
</StackPanel>
</StackPanel>
</StackPanel>
</Grid>
Expand Down
21 changes: 21 additions & 0 deletions src/Wpf.Ui.Test/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,25 @@ private void ShowMessageBox(Button self)
MessageBox.Error("This is a error message");
}
}

[RelayCommand]
private async Task AsyncShowMessageBoxAsync(Button self)
{
if (self.Content.ToString() == "Information")
{
await MessageBox.InformationAsync("This is a information message");
}
else if (self.Content.ToString() == "Warning")
{
await MessageBox.WarningAsync("This is a warning message");
}
else if (self.Content.ToString() == "Question")
{
await MessageBox.QuestionAsync("This is a question and do you want to click OK?");
}
else if (self.Content.ToString() == "Error")
{
await MessageBox.ErrorAsync("This is a error message");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<Thickness x:Key="ContentDialogTitleMargin">0,0,0,12</Thickness>
<Thickness x:Key="ContentDialogPadding">24</Thickness>
<GridLength x:Key="ContentDialogButtonSpacing">8</GridLength>
<SolidColorBrush x:Key="ContentDialogTopOverlay" Color="Transparent" />
<FontFamily x:Key="SymbolThemeFontFamily">pack://application:,,,/Wpf.Ui.Violeta;component/Resources/Fonts/Segoe Fluent Icons.ttf#Segoe Fluent Icons</FontFamily>

<WindowChrome
Expand Down

0 comments on commit 23836e0

Please sign in to comment.