feat: implement multi layer dialog.
This commit is contained in:
@@ -7,10 +7,11 @@
|
||||
x:CompileBindings="True"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Ursa.Demo.Dialogs.DialogWithAction">
|
||||
<StackPanel Margin="0 16 0 0">
|
||||
<TextBlock Text="{Binding Title}"></TextBlock>
|
||||
<StackPanel Margin="8">
|
||||
<TextBlock Classes="Strong" Margin="8" Text="{Binding Title}"></TextBlock>
|
||||
<Calendar SelectedDate="{Binding Date}" ></Calendar>
|
||||
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal" Spacing="20">
|
||||
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal" Spacing="8">
|
||||
<Button Content="Dialog" Command="{Binding DialogCommand}"></Button>
|
||||
<Button Content="OK" Command="{Binding OKCommand}"></Button>
|
||||
<Button Content="Cancel" Command="{Binding CancelCommand}"></Button>
|
||||
</StackPanel>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
@@ -16,10 +17,13 @@ public partial class DialogWithActionViewModel: ObservableObject, IDialogContext
|
||||
public ICommand OKCommand { get; set; }
|
||||
public ICommand CancelCommand { get; set; }
|
||||
|
||||
public ICommand DialogCommand { get; set; }
|
||||
|
||||
public DialogWithActionViewModel()
|
||||
{
|
||||
OKCommand = new RelayCommand(OK);
|
||||
CancelCommand = new RelayCommand(Cancel);
|
||||
DialogCommand = new AsyncRelayCommand(ShowDialog);
|
||||
Title = "Please select a date";
|
||||
Date = DateTime.Now;
|
||||
}
|
||||
@@ -33,4 +37,9 @@ public partial class DialogWithActionViewModel: ObservableObject, IDialogContext
|
||||
{
|
||||
Closed?.Invoke(this, false);
|
||||
}
|
||||
|
||||
private async Task ShowDialog()
|
||||
{
|
||||
await DialogBox.ShowOverlayModalAsync<DialogWithAction, DialogWithActionViewModel, bool>(new DialogWithActionViewModel(), "GlobalHost");
|
||||
}
|
||||
}
|
||||
@@ -21,15 +21,16 @@
|
||||
<Run Text="Date: "></Run>
|
||||
<Run Text="{Binding DialogViewModel.Date}"></Run>
|
||||
</TextBlock>
|
||||
<Button Command="{Binding ShowGlobalDialogCommand}">Show Dialog</Button>
|
||||
<Button Command="{Binding ShowLocalOverlayDialogCommand}">Show Local Overlay Dialog</Button>
|
||||
<Button Command="{Binding ShowGlobalOverlayDialogCommand}"> Show Global Overlay Dialog </Button>
|
||||
<Button Command="{Binding ShowGlobalModalDialogCommand}">Show 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>
|
||||
</StackPanel>
|
||||
<Grid Grid.Column="1">
|
||||
<Button
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Command="{Binding ShowLocalOverlayDialogCommand}">
|
||||
Command="{Binding ShowLocalOverlayModalDialogCommand}">
|
||||
Show Local Overlay Dialog
|
||||
</Button>
|
||||
<u:OverlayDialogHost HostId="LocalHost" />
|
||||
|
||||
@@ -11,9 +11,11 @@ namespace Ursa.Demo.ViewModels;
|
||||
|
||||
public class DialogDemoViewModel: ObservableObject
|
||||
{
|
||||
public ICommand ShowLocalOverlayDialogCommand { get; }
|
||||
public ICommand ShowLocalOverlayModalDialogCommand { get; }
|
||||
public ICommand ShowGlobalOverlayModalDialogCommand { get; }
|
||||
public ICommand ShowGlobalModalDialogCommand { get; }
|
||||
|
||||
public ICommand ShowGlobalOverlayDialogCommand { get; }
|
||||
public ICommand ShowGlobalDialogCommand { get; }
|
||||
|
||||
private object? _result;
|
||||
|
||||
@@ -35,27 +37,33 @@ public class DialogDemoViewModel: ObservableObject
|
||||
|
||||
public DialogDemoViewModel()
|
||||
{
|
||||
ShowLocalOverlayDialogCommand = new AsyncRelayCommand(ShowLocalOverlayDialog);
|
||||
ShowGlobalOverlayDialogCommand = new AsyncRelayCommand(ShowGlobalOverlayDialog);
|
||||
ShowGlobalDialogCommand = new AsyncRelayCommand(ShowGlobalDialog);
|
||||
ShowLocalOverlayModalDialogCommand = new AsyncRelayCommand(ShowLocalOverlayModalDialog);
|
||||
ShowGlobalOverlayModalDialogCommand = new AsyncRelayCommand(ShowGlobalOverlayModalDialog);
|
||||
ShowGlobalModalDialogCommand = new AsyncRelayCommand(ShowGlobalModalDialog);
|
||||
ShowGlobalOverlayDialogCommand = new RelayCommand(ShowGlobalOverlayDialog);
|
||||
}
|
||||
|
||||
private async Task ShowGlobalDialog()
|
||||
private void ShowGlobalOverlayDialog()
|
||||
{
|
||||
var result = await DialogBox.ShowAsync<DialogWithAction, DialogWithActionViewModel, bool>(DialogViewModel);
|
||||
DialogBox.ShowOverlay<DialogWithAction, DialogWithActionViewModel>(new DialogWithActionViewModel(), "GlobalHost");
|
||||
}
|
||||
|
||||
private async Task ShowGlobalModalDialog()
|
||||
{
|
||||
var result = await DialogBox.ShowModalAsync<DialogWithAction, DialogWithActionViewModel, bool>(DialogViewModel);
|
||||
Result = result;
|
||||
}
|
||||
|
||||
private async Task ShowGlobalOverlayDialog()
|
||||
private async Task ShowGlobalOverlayModalDialog()
|
||||
{
|
||||
Result = await DialogBox.ShowOverlayAsync<DialogWithAction, DialogWithActionViewModel, bool>(DialogViewModel, "GlobalHost");
|
||||
Result = await DialogBox.ShowOverlayModalAsync<DialogWithAction, DialogWithActionViewModel, bool>(DialogViewModel, "GlobalHost");
|
||||
}
|
||||
|
||||
private async Task ShowLocalOverlayDialog()
|
||||
private async Task ShowLocalOverlayModalDialog()
|
||||
{
|
||||
var vm = new DialogWithActionViewModel();
|
||||
var result = await DialogBox.ShowOverlayAsync<DialogWithAction, DialogWithActionViewModel, bool>(
|
||||
DialogViewModel, "LocalHost");
|
||||
var result = await DialogBox.ShowOverlayModalAsync<DialogWithAction, DialogWithActionViewModel, bool>(
|
||||
DialogViewModel, "LocalHost", new DialogOptions(){ ExtendToClientArea = true });
|
||||
Result = result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user