c# - ComboBox not updating display value after change -


i have following combobox on tab:

<combobox name="empnorulelistbox"           isreadonly="true"           itemssource="{binding adjustmentsettings.empnorulecollection}"            displaymemberpath="description"           selecteditem="{binding adjustmentsettings.selectedempnorule, mode=twoway}"            issynchronizedwithcurrentitem="true"            horizontalalignment="left"           width="300" /> 

and adjustmentsettings model is:

public class adjustmentsettingsmodel : modelbase<adjustmentsettingsmodel> {     public string company { get; set; }     public boolean reloademployeedata { get; set; }     public boolean sortbyname { get; set; }     public boolean applyjustificationrules { get; set; }     public int32 seednumber { get; set; }     public boolean scanformismatchedcodes { get; set; }     public boolean reloadhrtables { get; set; }      public empnorule selectedempnorule     {         { return _selectedempnorule; }         set         {             if (_selectedempnorule != value)             {                 _selectedempnorule = value;                 notifypropertychanged(m => m.selectedempnorule);             }         }     }     private empnorule _selectedempnorule;      public empnorulecollection empnorulecollection { get; set; } }  public class empnorulecollection : observablecollection<empnorule>, inotifypropertychanged {       . . .  }   public class empnorule : modelbase<empnorule> {     #region initialization & cleanup      // overriding gethashcode prevents clone operation marking      // object dirty when first cloned     public override int gethashcode()     {         return gethashcode(this);     }     private int gethashcode(object item, params string[] excludeprops)     {         int hashcode = 0;         foreach (var prop in item.gettype().getproperties())         {             if (!excludeprops.contains(prop.name))             {                 object propval = prop.getvalue(item, null);                 if (propval != null)                 {                     hashcode = hashcode ^ propval.gethashcode();                 }             }         }         return hashcode;     }       public override bool equals(system.object obj)     {         // if parameter null return false.         if (obj == null)         {             return false;         }          // if parameter cannot cast empnorule return false.         empnorule p = obj empnorule;         if ((system.object)p == null)         {             return false;         }          // return true if fields match:         return (obj == p);      }        public empnorule() { }      #endregion initialization & cleanup      /// <summary>     /// description     /// </summary>     [xmlelement("description")]     public string description     {                 {             return _description;         }         set         {             if (_description != value)             {                 this._description = value;                 notifypropertychanged(m => m.description);             }         }     }     private string _description = "";       /// <summary>     /// formula     /// </summary>     [xmlelement("formula")]     public string formula     {                 {             return _formula;         }         set         {             if (_formula != value)             {                 this._formula = value;                 notifypropertychanged(m => m.formula);             }         }     }     private string _formula = ""; } 

everything works correctly except displayed value in combobox not change when select different empnorule. value of selectedempnorule correctly set/updated , if change tab , come one, drop down value updated.

your code not show how update empnorulecollection property, assume reassigning new collection property. not update combobox unless publish propertychanged event on "empnorulecollection".

i believe reason why changing tab update combobox because binding pulls values empnorulecollection collection again when switch tab.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -