feat: implement buttons in different conditions.
This commit is contained in:
@@ -9,5 +9,9 @@
|
||||
x:Class="Ursa.Demo.Pages.MessageBoxDemo">
|
||||
<StackPanel HorizontalAlignment="Left">
|
||||
<Button Content="Default" Command="{Binding DefaultMessageBoxCommand}"></Button>
|
||||
<Button Content="OK" Command="{Binding OkCommand}" ></Button>
|
||||
<Button Content="OKCancel" Command="{Binding OkCancelCommand}" ></Button>
|
||||
<Button Content="YesNo" Command="{Binding YesNoCommand}" ></Button>
|
||||
<Button Content="YesNoCancel" Command="{Binding YesNoCancelCommand}" ></Button>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
|
||||
@@ -9,14 +9,42 @@ namespace Ursa.Demo.ViewModels;
|
||||
public class MessageBoxDemoViewModel: ObservableObject
|
||||
{
|
||||
public ICommand DefaultMessageBoxCommand { get; set; }
|
||||
public ICommand OkCommand { get; set; }
|
||||
public ICommand YesNoCommand { get; set; }
|
||||
public ICommand YesNoCancelCommand { get; set; }
|
||||
public ICommand OkCancelCommand { get; set; }
|
||||
|
||||
public MessageBoxDemoViewModel()
|
||||
{
|
||||
DefaultMessageBoxCommand = new AsyncRelayCommand(OnDefaultMessageAsync);
|
||||
OkCommand = new AsyncRelayCommand(OnOkAsync);
|
||||
YesNoCommand = new AsyncRelayCommand(OnYesNoAsync);
|
||||
YesNoCancelCommand = new AsyncRelayCommand(OnYesNoCancelAsync);
|
||||
OkCancelCommand = new AsyncRelayCommand(OnOkCancelAsync);
|
||||
}
|
||||
|
||||
private async Task OnDefaultMessageAsync()
|
||||
{
|
||||
var result = await MessageBox.ShowAsync("Hello Message Box");
|
||||
}
|
||||
|
||||
private async Task OnOkAsync()
|
||||
{
|
||||
var result = await MessageBox.ShowAsync("Hello Message Box", "Hello", MessageBoxButton.OK);
|
||||
}
|
||||
|
||||
private async Task OnYesNoAsync()
|
||||
{
|
||||
var result = await MessageBox.ShowAsync("Hello Message Box", "Hello", MessageBoxButton.YesNo);
|
||||
}
|
||||
|
||||
private async Task OnYesNoCancelAsync()
|
||||
{
|
||||
var result = await MessageBox.ShowAsync("Hello Message Box", "Hello", MessageBoxButton.YesNoCancel);
|
||||
}
|
||||
|
||||
private async Task OnOkCancelAsync()
|
||||
{
|
||||
var result = await MessageBox.ShowAsync("Hello Message Box", "Hello", MessageBoxButton.OKCancel);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user