I found the solution for my answer. It might no be the ultra clean way, but it works for me.
ViewModel:
private void LoadUi()
{
try
{
this.IsAdornerVisible = true;
RefreshCallback();
... some long going view initialization...
}
finally
{
this.IsAdornerVisible = false;
}
}
RefreshCallback is a property of type action, set by a method in code behind of the xaml. The method set to the RefreshCallback is this one:
private void Refresh()
{
this.Dispatcher.Invoke(new Action(() => { }), DispatcherPriority.ContextIdle, null);
}
The invoke on the dispatcher with ContextIdle makes that the rendering is done before the empty action is executed. With ContextIdle this works good. Before I tried other values of DispatcherPriority, for example Render. Did not work. Now I'm happy it works and weekend can begin.
The solution I found here: Source of my solution: Update the WPF UI now: how to wait for the rendering to finish