I have an application where I have to bind a Data Grid witch is on an User control in a Tab Item.
This process take a while so I create another Tab Item with a Loading animation in a separate thread and when I load data in data grid I select the tab item with the animation until the data is loaded.
The problem is that the animation is starting, but when the data grid binding starts, the animation is freezing.
this.Dispatcher.Invoke(DispatcherPriority.Normal,
new Action(
delegate()
{
tiLoading.Content = new Controls.Loading.LoadingAnimation();
tiLoading.IsSelected = true;
}
));
//And now I populate the content of the Tab Item with the User Control that contains data grid
connType = choseConnType(); // Here is a dialog witch ask the user somethig and return a value
tiGeneral.Content = new Windows.General(true, connType);
After the dialog when starts the binding the LoadingAnimation is freezing.
It’s understandable. If you have long-running process you should be using BackgroundWorker to run it.
And is it pretty to have your animation on different TabItem? Have you considered using
BusyIndicatorfrom Extended WPF Toolkit? You can simply wrap your Control with BusyIndicator and use Its IsBusy property to run it.