[2010] Adding ComboBox to ListView and binding to the selected value
I need to add a ComboBox to a ListView to display possible values of an Enum and bind the selected item to the value of a variable of that Enum. Unfortunately, my attempts are failing miserably and Google isn't helping much either.
Here's my code, I would appreciate it if you could take a look and tell me what I'm doing wrong.
Code:
<GridViewColumn Header=" Data " Width="Auto">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ComboBox Margin="0" MinWidth="50" SelectedItem="{Binding Mode=TwoWay, Path=ColumnType}" Width="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<TextBlock>Integer</TextBlock>
<TextBlock>Double</TextBlock>
</ComboBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
Also, the class I'm binding the controls to looks like this:
Code:
private class ListViewItemBinder
{
public CustomEnum ColumnType {get; set; }
}
I considered alternatives such as using the SelectedIndexChanged event etc, but that doesn't provide a way to set the initial value of the ComboBox...
Any help would be greatly appreciated.