In my WPF application I have a Grid with MouseDown, MouseUp and MouseMove events. I want the grid to disappear whenever I press the left mouse button, and reappear when I release it. The problem is that I don't get any mouse events while the grid is invisible (Visibility.Hidden).
This is the MouseDown handler:
private void TabHeaderOnMouseDown(object sender, MouseButtonEventArgs e)
{
tabHeader.CaptureMouse();
tabHeader.Visibility = Visibility.Hidden;
}
And the MouseUp handler:
private void TabHeaderOnMouseUp(object sender, MouseButtonEventArgs e)
{
tabHeader.ReleaseMouseCapture();
tabHeader.Visibility = Visibility.Visible;
}
Setting Opacity to 0 instead of changing the Visibility solved my problem.