c# - ObservableCollection and CollectionChanged Event -


Why does not the stored event fire in the following code, yet I can see new examples of inventory BTO, I Observable Collection?

Private Observe Collection & lt; Inventory BTO & gt; _inventoryRecords; Public Supervision Collection & lt; Inventory BTO & gt; Inventory Records {Meet {Return _Inventory Vacancies; } Set {_inventoryRecords = value; }} Private Inventory BTO _ Selected Records; Public Inventory BTO Selected Records {Get {return_selectedRecord; } Set {if (_selectedRecord! = Value) {_selectedRecord = value; OnPropertyChanged (New PropertyChangedEventArgs ("SelectedRecord")); }}} View public inventoryModel () {if (_inventoryRecords == empty) {Inventory Records = New Observe Collection & lt; InventoryBTO & gt; (); This.InventoryRecords.CollectionChanged + = New NotifyCollectionChangedEventHandler (InventoryRecords_CollectionChanged); } _inventoryRecords = Inventory LISTBTO.GetAllInventoryRecords (); } The problem is that zero inventory records_holan changes (object sender, notifyCollectionChangedEventArgs E) {}

That you are assigning your personal member to a new example of a observation code that you are coming back in your own way, so whatever is happening is linked to a collection status. But then to blow that example and move it with a new example you have to Vent handlers never bow down Here you can do what you can do by creating a class inherited from ObservableCollection and add an auditize method:

  public class category observerclone & Lt; T & gt; : Observable collection & lt; T & gt; {Private bool surpressEvents = false; Public Zero AddRange (IEnumerable & lt; T & gt; Items) {surpressEvents = true; Foreign items (different items in items) {base.Add (item); } This.surpressEvents = false; This.OncollectionChanged (New NotifyCollectionChangedEventArgs (NotifyCollectionChangedAction.Add, items.ToList ()); } Protected Override Zero On-Changing (System.clausures.spaced.notifcill-change event events e) {if (this.surpressEvents) {base.OnCollectionChanged (e); After this, you can change your class to:  
  Private Range Observe Collection & lt; Inventory BTO & gt; _inventoryRecords; Public Range Offbeat Collection & lt; Inventory BTO & gt; Inventory Records {Meet {Return _Inventory Vacancies; } Set {_inventoryRecords = value; }} Private Inventory BTO _ Selected Records; Public Inventory BTO Selected Records {Get {return_selectedRecord; } Set {if (_selectedRecord! = Value) {_selectedRecord = value; OnPropertyChanged (New PropertyChangedEventArgs ("SelectedRecord")); }}} View public inventoryModel () {if (_inventoryRecords == empty) {Inventory Records = New Observe Collection & lt; InventoryBTO & gt; (); This.InventoryRecords.CollectionChanged + = New NotifyCollectionChangedEventHandler (InventoryRecords_CollectionChanged); } This.InventoryRecords.AddRange (InventoryListBTO.GetAllInventoryRecords ()); } Zero Inventory Records / Ellen Chenzed (Object Sender, NotifyCollectionChangedEventArgs E) {//e.NewItems will be an ILID of all items that were added to the AddRange method ...}  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -