private void Window_Loaded(object sender, RoutedEventArgs e) { Startup = true; // Data source is handled in XAML !!!! if (this.BankGrid.Items.Count > 0) { this.BankGrid.Items.Clear( ); } this.BankGrid.ItemsSource = BankViewercollection; if (BankViewercollection.Count == 0) { BankViewercollection = BankCollection.LoadBank(4, false); } this.BankGrid.ItemsSource = BankViewercollection; this.MouseDown += delegate { DoDragMove( ); }; DataFields.DataContext = this.BankGrid.SelectedItem; EventControl.ViewerDataHasBeenChanged += ExternalDataUpdate; // Callback in THIS FILE //Subscribe to Bank Data Changed event declared in EventControl EventControl.BankDataLoaded += EventControl_BankDataLoaded; SaveBttn.IsEnabled = false; Startup = false; Count.Text = this.BankGrid.Items.Count.ToString( ); }
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( ); }