Reputation: 9508
I have Datagrid and I do something like:
Me.Cursor = Wait
Datagrid.ItemsSource = GetData()
Me.Cursor = Nothing
The problem is that there is a (relatively) large delay between setting the .ItemsSource and the moment when the rows actually rendered. So my cursor is reset to normal much too early.
Is there some kind of event that is raised when the Datagrid is finished loading/rendering the data? I know there is a _LoadingRow event, but it fires during the data load, not when the loading is completed?
Upvotes: 4
Views: 3343
Reputation: 875
I had the same issue (look here), and I solved it by placing this code after I changed the ItemsSource:
Dispatcher.InvokeAsync(() => { System.Windows.Input.Mouse.OverrideCursor = null; },
DispatcherPriority.ApplicationIdle);
It basically waits for the application to become idle before changing the cursor back to default. Using a FrameworkElement.Loaded event was not enough because it wouldn't get raised when I made changes to the ItemsSource, only when the datagrid was first loaded.
Upvotes: 4