void ReloadData(DataGrid DGrid) { try { Mouse.OverrideCursor = Cursors.Wait; // Make sure we are back on UI thread int current = 0; current = DGrid.SelectedIndex == -1 ? 0 : DGrid.SelectedIndex; this.BankGrid.ItemsSource = null; this.CustomerGrid.ItemsSource = null; this.DetailsGrid.ItemsSource = null; BankCollection.LoadBank(3); this.BankGrid.ItemsSource = MultiBankcollection; MultiCustcollection = CustCollection.LoadCust(MultiCustcollection); this.CustomerGrid.ItemsSource = MultiCustcollection; MultiDetcollection = DetCollection.LoadDet(MultiDetcollection); this.DetailsGrid.ItemsSource = MultiDetcollection; DGrid.SelectedIndex = current; Console.WriteLine($"End of ReloadGrid() : Thread = { Thread . CurrentThread . ManagedThreadId}"); } catch (Exception ex) { Console.WriteLine($"ERROR: ReloadGrid() {ex . Message}, : {ex . Data}"); } }
private async void Window_Loaded(object sender, RoutedEventArgs e) { Flags.MultiViewer = this; EventControl.BankDataLoaded += UpdatedDataLoaded; EventControl.CustDataLoaded += UpdatedDataLoaded; EventControl.DetDataLoaded += UpdatedDataLoaded; EventControl.ViewerDataHasBeenChanged += EventControl_ViewerDataHasBeenChanged; if (MultiBankcollection == null || MultiBankcollection.Count == 0) { MultiBankcollection = BankCollection.LoadBank(3); } BankGrid.ItemsSource = MultiBankcollection; if (MultiCustcollection == null || MultiCustcollection.Count == 0) { MultiCustcollection = CustCollection.LoadCust(MultiCustcollection); } if (MultiDetcollection == null || MultiDetcollection.Count == 0) { MultiDetcollection = DetCollection.LoadDet(MultiDetcollection); } this.BankGrid.ItemsSource = MultiBankcollection; this.CustomerGrid.ItemsSource = MultiCustcollection; this.DetailsGrid.ItemsSource = MultiDetcollection; }
private async void ReLoadAllDataBases( ) { this.BankGrid.ItemsSource = null; this.CustomerGrid.ItemsSource = null; this.DetailsGrid.ItemsSource = null; this.BankGrid.Items.Clear( ); this.CustomerGrid.Items.Clear( ); this.DetailsGrid.Items.Clear( ); BankCollection.LoadBank(3); MultiBankcollection = BankCollection.LoadBank(3); MultiCustcollection = CustCollection.LoadCust(MultiCustcollection); MultiDetcollection = DetCollection.LoadDet(MultiDetcollection); int b = bindex; int c = cindex; int d = dindex; this.BankGrid.ItemsSource = MultiBankcollection; this.CustomerGrid.ItemsSource = MultiCustcollection; this.DetailsGrid.ItemsSource = MultiDetcollection; bindex = b; cindex = c; dindex = d; this.BankGrid.Refresh( ); this.CustomerGrid.Refresh( ); this.DetailsGrid.Refresh( ); }