using Avalonia;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Markup.Xaml;
using System;
namespace AvaloniaDemo.Pages;
public partial class PositionControl : UserControl
{
PositionWindow positionWindow = new PositionWindow();
public PositionControl()
{
InitializeComponent();
Grid grid = new Grid();
}
private void PointerPressed(object? sender, PointerPressedEventArgs e)
{
positionWindow = new PositionWindow();
if (sender is Grid grid && this.VisualRoot is Window root)
{
if (grid.TranslatePoint(new Point(0, 0), root) is Point p)
{
var p1 = root.PointToScreen(p);
positionWindow.Position = p1;
positionWindow.ShowDialog(root);
}
}
}
}