BusyIndicator for datagrid

when I click a button, I load data into my datagrid

MySqlCommand cmd1m = new MySqlCommand("select * from table", conn); DataTable dt1m = new DataTable(); dt1m.Load(cmd1m.ExecuteReader()); System.Windows.Forms.BindingSource source = new System.Windows.Forms.BindingSource(); source.DataSource = dt1m; dataGrid1.ItemsSource = source; 

Namespace:

 xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended" 

and xaml:

 <wpf:BusyIndicator Name="loading" IsBusy="False"> <DataGrid>...</DataGrid> </<wpf:BusyIndicator> 

but the indicator does not work, why? What to do to make it work?

-3
source share
3 answers

In my WPF application, I created my own wait cursor class

 public class WaitCursor: IDisposable { private Cursor _previousCursor; public WaitCursor() { _previousCursor = Mouse.OverrideCursor; Mouse.OverrideCursor = Cursors.Wait; } pubic void Dispose() { Mouse.OverrideCursor = _previousCursor; } } 

and name it as follows

 //Some code for which you do not want wait cursor //.... using(new WaitCursor()) { dataGrid1.ItemsSource = source; } 
0
source

Setting IsBusy = "True" to the BusyIndicator will cause it to display an indicator.

In your case, bind the boolean property to IsBusy and make it True when loading data. After the download is complete, do it with False.

0
source

When performing the actions, you must toggle the IsBusy property.

  loading.IsBusy = true; // ... perform actions ... loading.IsBusy = false; 
0
source

Source: https://habr.com/ru/post/1268374/


All Articles