I have a WPF TabControl with two TabItems. I am trying to change the selected tab on code behind on a Button click event and execute some other code. In this example:
private void Button_Click(object sender, RoutedEventArgs e)
{
    ConvertDataTabControl.SelectedIndex = 1;
    System.Threading.Thread.Sleep(2000);
    ...
}
I would expect the UI to refresh and move from Tab 0 to Tab 1 and only then execute the Sleep method, but the UI is refreshed only after Button_Click finishes execution. I tried calling InvalidateVisual, but it does not work.
Is there a way to force the UI to refresh before executing Sleep?
 
     
     
     
    