title: WPF MVVM Binding refresh to display status
body: <p>I have a 'Load Data' process that could take anywhere from 1 to 20 seconds so I want to display a status message on my window. My window grid has a row which will be visible or hidden based upon a trigger which is bound to my view model. This works great. My problem is how I can change the binding and get the UI to refresh BEFORE my long running task starts. What happens now is that the Status property is set and then I start my task but the UI doesn't get refreshed until AFTER my task is complete. Here's my xaml and view model code.</p>
  
  <pre><code>&lt;Grid Grid.Row="4" Background="{StaticResource appPrimaryBackColorLight}" Height="20"&gt;
      &lt;Grid.Style&gt;
          &lt;Style TargetType="Grid"&gt;
              &lt;Style.Triggers&gt;
                  &lt;DataTrigger Binding="{Binding StatusMessageVisibility}" Value="Collapsed"&gt;
                      &lt;DataTrigger.EnterActions&gt;
                          &lt;BeginStoryboard&gt;
                              &lt;Storyboard&gt;
                                  &lt;DoubleAnimation Storyboard.TargetProperty="Height" From="20" To="0" Duration="0:0:0.1" /&gt;
                              &lt;/Storyboard&gt;
                          &lt;/BeginStoryboard&gt;
                      &lt;/DataTrigger.EnterActions&gt;
                      &lt;DataTrigger.ExitActions&gt;
                          &lt;BeginStoryboard&gt;
                              &lt;Storyboard&gt;
                                  &lt;DoubleAnimation Storyboard.TargetProperty="Height" From="0" To="20" Duration="0:0:.1" /&gt;
                              &lt;/Storyboard&gt;
                          &lt;/BeginStoryboard&gt;
                      &lt;/DataTrigger.ExitActions&gt;
                  &lt;/DataTrigger&gt;
              &lt;/Style.Triggers&gt;
          &lt;/Style&gt;
      &lt;/Grid.Style&gt;
      &lt;StackPanel Orientation="Horizontal" VerticalAlignment="Center"&gt;
          &lt;Image Width="20" Height="20" Grid.RowSpan="2" ani:ImageBehavior.AnimatedSource="/Images/spinner_status_20.gif"&gt;&lt;/Image&gt;
          &lt;TextBlock Text="{Binding StatusMessage}" Height="20" VerticalAlignment="Center" Padding="5,1,0,0" Style="{StaticResource appTextBlockSmallDark}" Foreground="White" /&gt;
      &lt;/StackPanel&gt;
  &lt;/Grid&gt;
  
  
  private void LoadImportData() 
  {
      // Show the status message by changing the view model properties
      StatusMessage = "Loading data from import file. Please stand by...";
      StatusMessageVisibility = Visibility.Visible;
  
      Task.Factory.StartNew(() =&gt;
                            {
                                //This invokes UI specific code inside module initialization
                                LoadDataNow();
                            }, CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.FromCurrentSynchronizationContext());
  }
  </code></pre>