I want to show a drag control (DataView) when the DragEnter event occurs and hide it when the DragLeave event fires. Since I also have children in the control, the leave event also fires when entering the child control. So I decided to only hide the control when the control receives a DragLeave event and the mouse is not within the complete drag control:
private void AView_DragLeave(object sender, DragEventArgs e)
{
var aPosition = e.GetPosition(DataView);
bool IsInside = (aPosition.X >= 5) && (aPosition.X < DataView.ActualWidth - 5) && (aPosition.Y >= 5) &&
(aPosition.Y < DataView.ActualHeight - 5);
DataView.Opacity = IsInside ? 1 : 0;
}
The problem now is that when DragLeave fires, the mouse is still inside the Data and I never come to the point where I have correct information to hide the control. Is there another solution for this problem. Getting the current mouse position does not work using Mouse.GetPosition() since the mouse location is not really tracked while drag&drop operations.