从 Silverlight 中的 ItemDragEventArgs 获取目标点

发布于 2024-11-15 01:35:20 字数 487 浏览 1 评论 0原文

如何从 ItemDragEventArgs 获取目标点?使用 Microsoft.Windows.DragEventArgs e 很简单:e.GetPosition(<该点相对于的 UIElement>)

XAML


<toolkit:PanelDragDropTarget AllowDrop="True" ItemDroppedOnTarget="DragAndDrop_ItemDroppedOnTarget">

<强>代码隐藏


private void DragAndDrop_ItemDroppedOnTarget(object sender, ItemDragEventArgs e)
{
   // how to get the destination Point here??
}

How does one get the destination point from ItemDragEventArgs? With Microsoft.Windows.DragEventArgs e it is easy: e.GetPosition(<UIElement to which the point is relative to>)

XAML


<toolkit:PanelDragDropTarget AllowDrop="True" ItemDroppedOnTarget="DragAndDrop_ItemDroppedOnTarget">

Code behind


private void DragAndDrop_ItemDroppedOnTarget(object sender, ItemDragEventArgs e)
{
   // how to get the destination Point here??
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

乞讨 2024-11-22 01:35:20

这看起来像是一个 hack,但它有效并且非常准确:


private Point _releasePoint;

public Grid()
{
   Grid.MouseLeftButtonUp += new MouseButtonEventHandler(Grid_MouseLeftButtonUp);
}

void Grid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
   _releasePoint = e.GetPosition(Grid);
}

private void DragAndDrop_ItemDroppedOnTarget(object sender, ItemDragEventArgs e)
{
   // fires next and _releasePoint is already set
}

This looks like a hack, but it worked and is pretty accurate:


private Point _releasePoint;

public Grid()
{
   Grid.MouseLeftButtonUp += new MouseButtonEventHandler(Grid_MouseLeftButtonUp);
}

void Grid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
   _releasePoint = e.GetPosition(Grid);
}

private void DragAndDrop_ItemDroppedOnTarget(object sender, ItemDragEventArgs e)
{
   // fires next and _releasePoint is already set
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文