I have a window with a grid and periodically I need to turn whole screen black.
In order to do that I set grid visibility to hidden:
mainGrid.Visibility = Visibility.Hidden;
then, after one second, I change it back to Visible
.
But after setting visibility to hidden, screen doesn't change at all.
I tried UpdateLayout
, InvalidateArrange
, nithing worked...
How to get the grid to hide and reappear again?
Whole code:
mainGrid.Visibility = Visibility.Hidden;
mainGrid.UpdateLayout();
Thread.Sleep(1000);
mainGrid.Visibility = Visibility.Visible;
mainGrid.UpdateLayout();