How to set the value for a ComboBoxItem in XAML? RRS feed

  • Question

  • I create a datatemplate for a combobox as follows:

    <DataTemplate x:Key="AircraftTypeTemplate"> 

         <StackPanel Orientation="Horizontal" Width="340"> 










    It renders fine, but I would like to be able to associate a value with each of the items without having to bind it to some data context. For example I would like the CJ1 comboboxitem to have a value of 5. How would I set those in XAML?
      <ComboBoxItem Value="5">CJ1</ComboBoxItem> 


    I have thought of setting the Tag property of each ComboBoxitem but then how would I bind the SelectedValue of the combobox to the Tag?


    Thursday, October 27, 2011 4:20 PM