public CustomerView() { InitializeComponent(); LoadingIndicatorPanel.Visibility = Visibility.Visible; MainContent.IsEnabled = false; Task.Factory.StartNew(() => { var customersVM = new CustomersViewModel(); customersVM.RefreshCustomers(); var result = Application.Current.Dispatcher.BeginInvoke( DispatcherPriority.Background, new Action(() => { customersView = new CustomersView(); customersView.CustomersVM = customersVM; frameCustomers.Content = customersView; customersView.dgCustomers.SelectionChanged += DgCustomers_SelectionChanged; AssigneValuesToControl(); customersView.dgCustomers.SelectedIndex = 0; EnableContoles(false); })); }).ContinueWith((task) => { LoadingIndicatorPanel.Visibility = Visibility.Collapsed; MainContent.IsEnabled = true; }, TaskScheduler.FromCurrentSynchronizationContext()); //TODO Add refresh button to refrexh all data }