c# - Retrieve specific Uid from Selected ComboBoxItem in a ComboBox in WPF -


how can uid comboboxitem selected user?

i have following code in xaml

<combobox x:name="cmbcat" horizontalalignment="left" margin="210,163,0,0" verticalalignment="top" width="183" background="white">             <comboboxitem content="computing , it" uid="2001"/>             <comboboxitem content="electrical" uid="2002"/>             <comboboxitem content="stationery" uid="2003"/>             <comboboxitem content="building" uid="2004"/>         </combobox> 

and i'd specific uid, whichever selected user in combobox.

you can uid setting "sectionchanged" event on combobox , getting value combobox item.

xaml:

<combobox x:name="cmbcat" horizontalalignment="left" margin="210,163,0,0"            verticalalignment="top" width="183" background="white" selectionchanged="cmbcat_selectionchanged">     <comboboxitem content="computing , it" uid="2001"/>     <comboboxitem content="electrical" uid="2002"/>     <comboboxitem content="stationery" uid="2003"/>     <comboboxitem content="building" uid="2004"/> </combobox> 

code behind:

private void cmbcat_selectionchanged(object sender, selectionchangedeventargs e) {     var combobox = sender combobox;     if (null != combobox)     {         var item = combobox.selecteditem comboboxitem;         if (null != item)         {             console.writeline(item.uid);         }     } } 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -