Fixed: The propagation issue of OverlayFeedbackElement.ClosedEvent.
This commit is contained in:
@@ -7,27 +7,19 @@
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Sandbox.Views.MainWindow"
|
||||
x:DataType="vm:MainWindowViewModel"
|
||||
xmlns:sys="using:System"
|
||||
Icon="/Assets/avalonia-logo.ico"
|
||||
Title="Sandbox">
|
||||
|
||||
<Design.DataContext>
|
||||
<!-- This only sets the DataContext for the previewer in an IDE,
|
||||
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
|
||||
<vm:MainWindowViewModel/>
|
||||
<vm:MainWindowViewModel />
|
||||
</Design.DataContext>
|
||||
|
||||
<Grid>
|
||||
<u:Form>
|
||||
<u:FormItem Label="_Numeric">
|
||||
<u:NumericIntUpDown/>
|
||||
</u:FormItem>
|
||||
<u:FormItem Label="_AnotherNumeric">
|
||||
<u:NumericIntUpDown/>
|
||||
</u:FormItem>
|
||||
<u:FormItem Label="_TextBox">
|
||||
<TextBox/>
|
||||
</u:FormItem>
|
||||
</u:Form>
|
||||
</Grid>
|
||||
|
||||
</Window>
|
||||
<u:UrsaView>
|
||||
<Panel>
|
||||
<Button Content="???" Click="Button_OnClick"></Button>
|
||||
<u:OverlayDialogHost HostId="root"></u:OverlayDialogHost>
|
||||
</Panel>
|
||||
</u:UrsaView>
|
||||
</Window>
|
||||
@@ -1,4 +1,6 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Ursa.Controls;
|
||||
|
||||
namespace Sandbox.Views;
|
||||
|
||||
@@ -8,4 +10,9 @@ public partial class MainWindow : Window
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private async void Button_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
var res = await OverlayDialog.ShowModal(new TextBlock() { Text = "sdfksjdl" }, "root");
|
||||
}
|
||||
}
|
||||
15
demo/Sandbox/Views/PW.axaml
Normal file
15
demo/Sandbox/Views/PW.axaml
Normal file
@@ -0,0 +1,15 @@
|
||||
<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="Sandbox.Views.PW">
|
||||
<Panel>
|
||||
<Button Content="???" Click="Button_OnClick"></Button>
|
||||
<Button Content="close" VerticalAlignment="Bottom" Click="Close"></Button>
|
||||
<u:OverlayDialogHost x:Name="_overlayDialogHost" ></u:OverlayDialogHost>
|
||||
</Panel>
|
||||
</UserControl>
|
||||
42
demo/Sandbox/Views/PW.axaml.cs
Normal file
42
demo/Sandbox/Views/PW.axaml.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Irihi.Avalonia.Shared.Contracts;
|
||||
using Sandbox.ViewModels;
|
||||
using Ursa.Controls;
|
||||
|
||||
namespace Sandbox.Views;
|
||||
|
||||
public partial class PW : UserControl
|
||||
{
|
||||
public PW()
|
||||
{
|
||||
InitializeComponent();
|
||||
_overlayDialogHost.HostId = _hostid;
|
||||
}
|
||||
|
||||
private string _hostid = Path.GetRandomFileName();
|
||||
|
||||
private async void Button_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
Drawer.ShowCustom(new PW(), new TestVM(), _hostid);
|
||||
}
|
||||
|
||||
private void Close(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
(DataContext as TestVM)?.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public class TestVM : ViewModelBase, IDialogContext
|
||||
{
|
||||
public void Close()
|
||||
{
|
||||
RequestClose?.Invoke(this, 12456789);
|
||||
}
|
||||
|
||||
public event EventHandler<object?>? RequestClose;
|
||||
}
|
||||
Reference in New Issue
Block a user