c# - WPF Combo box - Select Item by Tag -


i have combo box this

    <combobox name="mymenu">         <comboboxitem content="question 1" tag="1"  />         <comboboxitem content="question 2" tag="2"  />         <comboboxitem content="question 3" tag="3"  />         <comboboxitem content="question 4" tag="4"  />     </combobox> 

how can programmatically set selected index tag value? e.g. 'mymenu.selectedtag = 3' , question 3 selected item?

i want easier current solution really...

      int tagtoselect = 3;       foreach (comboboxitem item in mymenu.items)       {           if(item.tag.equals(tagtoselect)           {                mymenu.selecteditem = item;           }       } 

looks you're looking proeprty selectedvaluepath of combobox control. see example here http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.selector.selectedvaluepath.aspx


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -