feat: implement default control and window mode.

This commit is contained in:
rabbitism
2024-01-25 15:06:39 +08:00
parent 87bb47b4e1
commit 20f723b445
15 changed files with 331 additions and 88 deletions

View File

@@ -3,8 +3,6 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
Padding="24"
Background="Aqua"
x:Class="Ursa.Demo.Dialogs.PlainDialog">
<StackPanel>
<Calendar SelectedDate="{Binding Date}" ></Calendar>

View File

@@ -21,11 +21,11 @@
<Run Text="Date: "></Run>
<Run Text="{Binding DialogViewModel.Date}"></Run>
</TextBlock>
<Button Command="{Binding ShowGlobalModalDialogCommand}">Show Modal Dialog</Button>
<Button Command="{Binding ShowDefaultWindowCommand}">Show Default Modal Dialog</Button>
<Button Command="{Binding ShowGlobalModalDialogCommand}">Show Custom Modal Dialog</Button>
<Button Command="{Binding ShowLocalOverlayModalDialogCommand}">Show Local Overlay Modal Dialog</Button>
<Button Command="{Binding ShowGlobalOverlayModalDialogCommand}"> Show Global Overlay Modal Dialog </Button>
<Button Command="{Binding ShowGlobalOverlayDialogCommand}">Show Global Overlay Dialog</Button>
<Button Command="{Binding ShowPlainGlobalOverlayDialogCommand}">Default Buttons</Button>
</StackPanel>
<Grid Grid.Column="1">
<Button

View File

@@ -16,7 +16,7 @@ public class DialogDemoViewModel: ObservableObject
public ICommand ShowGlobalOverlayModalDialogCommand { get; }
public ICommand ShowGlobalModalDialogCommand { get; }
public ICommand ShowGlobalOverlayDialogCommand { get; }
public ICommand ShowPlainGlobalOverlayDialogCommand { get; }
public ICommand ShowDefaultWindowCommand { get; }
private object? _result;
public object? Result
@@ -41,12 +41,20 @@ public class DialogDemoViewModel: ObservableObject
ShowGlobalOverlayModalDialogCommand = new AsyncRelayCommand(ShowGlobalOverlayModalDialog);
ShowGlobalModalDialogCommand = new AsyncRelayCommand(ShowGlobalModalDialog);
ShowGlobalOverlayDialogCommand = new RelayCommand(ShowGlobalOverlayDialog);
ShowPlainGlobalOverlayDialogCommand = new AsyncRelayCommand(ShowPlainGlobalOverlayDialog);
ShowDefaultWindowCommand = new AsyncRelayCommand(ShowDefaultWindow);
}
private async Task ShowDefaultWindow()
{
var result = await Dialog.ShowModalAsync<PlainDialog, PlainDialogViewModel>(new PlainDialogViewModel(),
mode: DialogMode.Error, buttons: DialogButton.OKCancel, title:"确定取消预约吗?");
Result = result;
return;
}
private void ShowGlobalOverlayDialog()
{
OverlayDialog.Show<DialogWithAction, DialogWithActionViewModel>(new DialogWithActionViewModel());
OverlayDialog.ShowCustom<DialogWithAction, DialogWithActionViewModel>(new DialogWithActionViewModel());
}
private async Task ShowGlobalModalDialog()
@@ -57,21 +65,15 @@ public class DialogDemoViewModel: ObservableObject
private async Task ShowGlobalOverlayModalDialog()
{
Result = await OverlayDialog.ShowCustomModalAsync<DialogWithAction, DialogWithActionViewModel, bool>(DialogViewModel);
Result = await OverlayDialog.ShowModalAsync<PlainDialog, PlainDialogViewModel>(new PlainDialogViewModel(),
title: "Please select a date", mode: DialogMode.Error, buttons: DialogButton.YesNoCancel);
}
private async Task ShowLocalOverlayModalDialog()
{
var vm = new DialogWithActionViewModel();
var result = await OverlayDialog.ShowCustomModalAsync<DialogWithAction, DialogWithActionViewModel, bool>(
DialogViewModel, "LocalHost");
vm, "LocalHost");
Result = result;
}
public async Task ShowPlainGlobalOverlayDialog()
{
var result = await OverlayDialog.ShowCustomModalAsync<PlainDialog, PlainDialogViewModel, object?>(
new PlainDialogViewModel(),
"LocalHost");
}
}