I currently have a column that binds to a collection of enums. I'm trying to change it so that it will display the display attribute name instead of the enum name. I was able to the the CellTemplate to display the correct attribute name but I wasn't able to get the CellEditTemplate to display the the dropdown correct. It doesn't show anything when clicked.
My original code that works but doesn't use display name
<telerik:GridViewComboBoxColumn Header="Event Type" ItemsSource="{Binding ScriptEvents}" DataMemberBinding="{Binding SelectedEvent}" IsReadOnly="False" />
What I tried
<telerik:GridViewComboBoxColumn ItemsSource="{Binding ScriptEvents}" DataMemberBinding="{Binding SelectedEvent}" IsReadOnly="False">
<telerik:GridViewComboBoxColumn.CellTemplate >
<DataTemplate>
<TextBlock Text="{Binding SelectedEvent, Converter={StaticResource EnumToDisplayAttribConverter}}"/>
</DataTemplate>
</telerik:GridViewComboBoxColumn.CellTemplate>
<telerik:GridViewComboBoxColumn.CellEditTemplate >
<DataTemplate>
<telerik:RadComboBox ItemsSource="{Binding ScriptEvents, RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}}">
<telerik:RadComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding SelectedEvent, Converter={StaticResource EnumToDisplayAttribConverter}}" DataContext="{Binding}"/>
</DataTemplate>
</telerik:RadComboBox.ItemTemplate>
</telerik:RadComboBox>
</DataTemplate>
</telerik:GridViewComboBoxColumn.CellEditTemplate>
</telerik:GridViewComboBoxColumn>
Code for enum converter can be found here http://formatexception.com/2014/07/bind-a-combobox-to-an-enum-while-using-display-attribute/
My original code that works but doesn't use display name
<telerik:GridViewComboBoxColumn Header="Event Type" ItemsSource="{Binding ScriptEvents}" DataMemberBinding="{Binding SelectedEvent}" IsReadOnly="False" />
What I tried
<telerik:GridViewComboBoxColumn ItemsSource="{Binding ScriptEvents}" DataMemberBinding="{Binding SelectedEvent}" IsReadOnly="False">
<telerik:GridViewComboBoxColumn.CellTemplate >
<DataTemplate>
<TextBlock Text="{Binding SelectedEvent, Converter={StaticResource EnumToDisplayAttribConverter}}"/>
</DataTemplate>
</telerik:GridViewComboBoxColumn.CellTemplate>
<telerik:GridViewComboBoxColumn.CellEditTemplate >
<DataTemplate>
<telerik:RadComboBox ItemsSource="{Binding ScriptEvents, RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}}">
<telerik:RadComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding SelectedEvent, Converter={StaticResource EnumToDisplayAttribConverter}}" DataContext="{Binding}"/>
</DataTemplate>
</telerik:RadComboBox.ItemTemplate>
</telerik:RadComboBox>
</DataTemplate>
</telerik:GridViewComboBoxColumn.CellEditTemplate>
</telerik:GridViewComboBoxColumn>
Code for enum converter can be found here http://formatexception.com/2014/07/bind-a-combobox-to-an-enum-while-using-display-attribute/