DataGridComboBoxColumn SelectedItem Bind to int property

Jun 26, 2009 at 6:24 PM

Trying to bind SelectedIndex of DataGridComboBoxColumn to an integer property. Works fine if property is a string and the string name matches the item in the ComboBox of course, but values in my case are int's that I would like to select the index. Seems simple enough. It does not appear to bind to an int as nicely as the standard .NET combo box does. I have read the thread on the bool binding, I think it has to be simpler than that, no?

Here is the property:

        public int GainMode




                return m_iGainMode;





                m_iGainMode = value;



Here is the Zaymel:

<WPFToolkit:DataGrid AutoGenerateColumns="False" Name="grdGain">
      <WPFToolkit:DataGridComboBoxColumn Header ="Mode" Width="80"
                   SelectedItemBinding="{Binding Path=GainMode}"

Any suggestions?

Jun 26, 2009 at 8:56 PM

I assume that GainMode is the index of selected item into you items source. Here are few points to consider...

  • I dont think that SelectedValuePath or SelectedItemBinding are relavent here.
  • Use ElementStyle and EditingElementStyle on DataGridComboBoxColumn to Bind SelectedIndex to GainMode property.
  • Make sure that GainMode is either backed by a DependencyProperty or INotifyPropertyChanged
Jun 26, 2009 at 9:55 PM

Got you, Thanks, I am on it :)