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
Post a Comment