csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.2 KiB
47 lines
1.2 KiB
using Avalonia;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Input;
|
|
|
|
namespace IntegrationTestApp.Pages;
|
|
|
|
public partial class PointerPage : UserControl
|
|
{
|
|
public PointerPage()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void PointerPageShowDialog_PointerPressed(object? sender, PointerPressedEventArgs e)
|
|
{
|
|
void CaptureLost(object? sender, PointerCaptureLostEventArgs e)
|
|
{
|
|
PointerCaptureStatus.Text = "None";
|
|
((Control)sender!).PointerCaptureLost -= CaptureLost;
|
|
}
|
|
|
|
var window = TopLevel.GetTopLevel(this) as Window ??
|
|
throw new AvaloniaInternalException("PointerPage is not attached to a Window.");
|
|
var captured = e.Pointer.Captured as Control;
|
|
|
|
if (captured is not null)
|
|
{
|
|
captured.PointerCaptureLost += CaptureLost;
|
|
}
|
|
|
|
PointerCaptureStatus.Text = captured?.ToString() ?? "None";
|
|
|
|
var dialog = new Window
|
|
{
|
|
Width = 200,
|
|
Height = 200,
|
|
};
|
|
|
|
dialog.Content = new Button
|
|
{
|
|
Content = "Close",
|
|
Command = new DelegateCommand(() => dialog.Close()),
|
|
};
|
|
|
|
dialog.ShowDialog(window);
|
|
}
|
|
}
|
|
|