Add:OverlayFeedbackElement.ClosedEvent fixed HeadlessTest.

This commit is contained in:
望尘空忧
2025-01-15 22:01:48 +08:00
parent 93fe82c100
commit 87060da654
3 changed files with 69 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:u="https://irihi.tech/ursa"
MinHeight="200"
MinWidth="500"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="HeadlessTest.Ursa.Controls.DrawerCloseTestPopupControl">
<u:OverlayDialogHost x:Name="_overlayDialogHost" ></u:OverlayDialogHost>
</UserControl>

View File

@@ -0,0 +1,43 @@
using System;
using System.ComponentModel;
using System.IO;
using System.Runtime.CompilerServices;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using Ursa.Controls;
namespace HeadlessTest.Ursa.Controls;
public partial class DrawerCloseTestPopupControl : UserControl
{
public DrawerCloseTestPopupControl()
{
InitializeComponent();
_overlayDialogHost.HostId = _hostid;
}
private readonly string _hostid = Path.GetRandomFileName();
public DrawerCloseTestPopupControl Popup { get; set; }
public int LResult { get; set; }
public int RResult { get; set; }
public async void OpenPopup()
{
var vm = new DrawerCloseTestPopupControlVM();
LResult = vm.Result;
RResult = await Drawer.ShowCustomModal<int>(Popup = new(), vm, _hostid);
}
public void ClosePopup()
{
(Popup.DataContext as DrawerCloseTestPopupControlVM)?.Close();
}
public void Close()
{
(DataContext as DrawerCloseTestPopupControlVM)?.Close();
}
}

View File

@@ -0,0 +1,15 @@
using Irihi.Avalonia.Shared.Contracts;
namespace HeadlessTest.Ursa.Controls;
public class DrawerCloseTestPopupControlVM : IDialogContext
{
public void Close()
{
RequestClose?.Invoke(this, Result);
}
public int Result { get; } = Random.Shared.Next();
public event EventHandler<object?>? RequestClose;
}