mvvm - Binding ComboBox selected Item to a property of the View Model -


hi trying bind combobox selected item property in view model setter take value , perform other logic. combobox working correctly pulling items off observablecollection systems have been unable bind selecteditem serial property. selected item not getting string value of combobox. eveything else ok datacontext assigned view in code behind. ideas viewmodel:

public class cablingrequests : observablecollection<cablingrequest> {     public observablecollection<cablingrequest> pendingrequests { get; set; }     public observablecollection<cablingrequest> processedrequests { get; set; }     public observablecollection<cablingrequest> systems { get; set; }     public observablecollection<cablingrequest> selectedsystemconfiguration { get; set; }      private string _serial;     public string serial     {         { return _serial; }         set         {             if (_serial == value)                 return;             _serial = value;             getselectedsystemconfiguration(_serial);         }     } 

and xaml code of combobox:

<combobox x:name="comboboxserial" itemssource="{binding path=systems}"  displaymemberpath="serialnumber" selectedvalue="{binding path=serial, mode=twoway}"  issynchronizedwithcurrentitem="true" minwidth="150" /> 

your combobox bound collection of cablingrequest, should either bind selecteditem instance of cablingrequest, or if want serial number, should set selectedvaluepath 'serialnumber' property of cablingrequest type.

see difference between selecteditem, selectedvalue , selectedvaluepath more information.


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -