Refereshing window : <p>I have a window with a grid and periodically I need to turn whole screen black.</p>

<p>In order to do that I set grid visibility to hidden:</p>

<pre><code>mainGrid.Visibility = Visibility.Hidden;
</code></pre>

<p>then, after one second, I change it back to <code>Visible</code>.</p>

<p>But after setting visibility to hidden, screen doesn't change at all.</p>

<p>I tried <code>UpdateLayout</code>, <code>InvalidateArrange</code>, nithing worked...</p>

<p>How to get the grid to hide and reappear again?</p>

<p>Whole code:</p>

<pre><code>mainGrid.Visibility = Visibility.Hidden;
mainGrid.UpdateLayout();
Thread.Sleep(1000);
mainGrid.Visibility = Visibility.Visible;
mainGrid.UpdateLayout();
</code></pre>
