How to bind collection to WPF:DataGridComboBoxColumn
- by everwicked
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