How to bind collection to WPF:DataGridComboBoxColumn

Posted by everwicked on Stack Overflow See other posts from Stack Overflow or by everwicked
Published on 2010-05-22T23:32:08Z Indexed on 2010/05/24 10:41 UTC
Read the original article Hit count: 1057

Filed under:
|
|

Admittedly I am new to WPF but I have looked and looked and can't find a solution to this problem.

I have a simple object like:

class Item
{
  ....

  public String Measure { get; set; }
  public String[] Measures {get; }
}

Which I am trying to bind to a DataGrid with two text columns and a combo box column. For the combo box column, propery Measure is the current selection and Measures the possible values.

My XAML is:

                        <DataGridComboBoxColumn Header="Measure" Width="Auto"
                                                SelectedItemBinding="{Binding Path=Measure}"
                                                ItemsSource="{Binding Path=Measures}"/>

                    </DataGrid.Columns>
                </DataGrid>

The text column are displayed just fine but the combobox is not - the values are not displayed at all. The binding error is :

¨System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=Measures; DataItem=null; target element is 'DataGridComboBoxColumn' (HashCode=11497055); target property is 'ItemsSource' (type 'IEnumerable')

How do I fix this???

Thanks

© Stack Overflow or respective owner

Related posts about c#

Related posts about wpf