public MainWindow() { InitializeComponent(); Instance = this; AccountsDataGrid.ItemsSource = Checker.Accounts.Where(a => a.State == Account.Result.Success); Loaded += WindowLoaded; Closed += WindowClosed; }
public MainWindow() { InitializeComponent(); Instance = this; AccountsDataGrid.ItemsSource = CheckedAccountsView; AccountsDataGrid.PreviewKeyDown += Utils.AccountsDataDataGridSearchByLetterKey; AccountsDataGrid.Loaded += (s, e) => { foreach(var col in AccountsDataGrid.Columns) { col.MinWidth = col.ActualWidth; col.Width = new DataGridLength(1, DataGridLengthUnitType.Star); } }; Loaded += WindowLoaded; Closed += WindowClosed; Checker.Accounts.CollectionChanged += (sender, args) => { if (args != null) { if (args.NewItems != null) { foreach (INotifyPropertyChanged item in args.NewItems) { item.PropertyChanged += (s, e) => UpdateControls(); } foreach (Account acc in args.NewItems) { acc.PropertyChanged += (o, e) => { if (e.PropertyName == nameof(Account.State)) { CheckedAccountsView.Refresh(); } }; } } if (args.OldItems != null) { foreach (INotifyPropertyChanged item in args.OldItems) { item.PropertyChanged -= (s, e) => UpdateControls(); } } } UpdateControls(); }; UpdateControls(); }
public MainWindow() { InitializeComponent(); Instance = this; _accountsDataGrid.ItemsSource = Checker.Accounts.Where(a => a.State == Account.Result.Success); // Init Regions _regionsComboBox.ItemsSource = Enum.GetValues(typeof(Region)).Cast<Region>(); _regionsComboBox.SelectedItem = Settings.Config.SelectedRegion; Loaded += WindowLoaded; Closed += WindowClosed; }