feat: add overlay dialog sample.

This commit is contained in:
rabbitism
2024-01-22 18:32:24 +08:00
parent 5c62131a0a
commit f0ec32c870
10 changed files with 139 additions and 9 deletions

View File

@@ -0,0 +1,36 @@
using System;
using System.Windows.Input;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Ursa.Controls;
namespace Ursa.Demo.Dialogs;
public partial class DialogWithActionViewModel: ObservableObject, IDialogContext
{
[ObservableProperty] private string _title;
[ObservableProperty] private DateTime _date;
public object? DefaultCloseResult { get; set; } = true;
public event EventHandler<object>? Closed;
public ICommand OKCommand { get; set; }
public ICommand CancelCommand { get; set; }
public DialogWithActionViewModel()
{
OKCommand = new RelayCommand(OK);
CancelCommand = new RelayCommand(Cancel);
Title = "Please select a date";
Date = DateTime.Now;
}
private void OK()
{
Closed?.Invoke(this, true);
}
private void Cancel()
{
Closed?.Invoke(this, false);
}
}