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.
Also, the class I'm binding the controls to looks like this: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>
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...Code:private class ListViewItemBinder { public CustomEnum ColumnType {get; set; } }
Any help would be greatly appreciated.



Reply With Quote
