2011-06-12 43 views
2

如何從ItemDragEventArgs獲取目標點?隨着Microsoft.Windows.DragEventArgs e很容易:e.GetPosition(<UIElement to which the point is relative to>)在Silverlight中從ItemDragEventArgs獲取目標點

XAML


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

背後


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

回答

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 
}