Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a DataGrid "rendering complete" event?

When I load my DataGrid, I change the cursor to the wait-icon, load data into my ItemsSource from a database, and then set the cursor back to default. This works great, except for the fact that there is a delay in between when the ItemsSource is populated and when the DataGrid actually renders the data, so the cursor changes back to default too early.

Is there an event that is fired when a DataGrid is completely done rendering so that my cursor can return to default at the correct time?

like image 313
Drew Jex Avatar asked May 30 '17 21:05

Drew Jex


People also ask

What is the difference between grid and DataGrid in WPF?

A Grid is a control for laying out other controls on the form (or page). A DataGrid is a control for displaying tabular data as read from a database for example.

What is WPF DataGrid?

The WPF Data Grid (GridControl) is a data-aware control designed to display and edit data in different layouts: tabular, treelike, and card. The GridControl allows users to manage large amounts of data (sort, group, filter, and so on).


1 Answers

FrameworkElement.Loaded event

Occurs when the element is laid out, rendered, and ready for interaction.

Edit

Or, just after you change the DataSource execute the following. So, it will reset the Cursor when application is idle.

    Dispatcher.InvokeAsync(() => { System.Windows.Input.Mouse.OverrideCursor = null; }, 
        DispatcherPriority.ApplicationIdle);
like image 80
CharithJ Avatar answered Oct 07 '22 09:10

CharithJ