从Silverlight中的ItemDragEventArgs获取目标点

时间:2011-06-12 06:07:43

标签: silverlight silverlight-4.0 silverlight-toolkit

如何从ItemDragEventArgs获取目的地点?使用Microsoft.Windows.DragEventArgs e很容易:e.GetPosition(<UIElement to which the point is relative to>)

XAML


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

代码


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

1 个答案:

答案 0 :(得分:0)

这看起来像一个黑客,但它起作用并且非常准确:


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
}