Hi,
I'm using RadGridView to display object's properties, like a PropertyGrid.
I need to change the template of the cell according to the type of the property.
I defined templates for text, color, and enum, also two template selectors, one for edit and one for normal mode.
For example, an enum should be edit by choosing an item out of a combobox and to be displayed in a TextBlock.
The problem, is when I set the enum template for both the edit selector and normal selector, the combobox is not displayed in edit mode, like this template is ignored.
In resources:
<DataTemplate x:Key="TextPropertyValueEditTemplate">
<TextBox Text="{Binding PropertyValue, Mode=TwoWay}" />
</DataTemplate>
<DataTemplate x:Key="ColorPropertyValueEditTemplate">
<telerik:RadColorPicker SelectedColor="{Binding PropertyValue, Mode=TwoWay}" ColorButtonStyle="{StaticResource ColorButtonStyle}" />
</DataTemplate>
<DataTemplate x:Key="EnumPropertyValueEditTemplate">
<ComboBox Text="{Binding PropertyValue, Mode=OneWay}"
SelectedValue="{Binding PropertyValue, Mode=TwoWay}"
ItemsSource="{Binding EnumNames}" />
</DataTemplate>
<DataTemplate x:Key="EnumPropertyValueNormalTemplate"><TextBox Text="{Binding PropertyValue}" />
</DataTemplate>
<Controls:PropertyValueDataTemplateSelector x:Key="PropertyValueEditTemplateSelector"
TextTemplate="{StaticResource TextPropertyValueEditTemplate}"
ColorTemplate="{StaticResource ColorPropertyValueEditTemplate}"
EnumTemplate="{StaticResource EnumPropertyValueEditTemplate}"
/>
<Controls:PropertyValueDataTemplateSelector x:Key="PropertyValueTemplateSelector"
ColorTemplate="{StaticResource ColorPropertyValueEditTemplate}"
EnumTemplate="{StaticResource TextPropertyValueEditTemplate}"
/>
In the grid:
<telerik:RadGridView Name="dataGrid1"
AutoGenerateColumns="False"
ShowGroupPanel="False"
ShowColumnHeaders="False"
>
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn Header="Name" Width="120"
DataMemberBinding="{Binding PropertyName}"/>
<telerik:GridViewDataColumn Header="Value" Width="100*"
DataMemberBinding="{Binding PropertyValue}"
CellTemplateSelector="{StaticResource PropertyValueTemplateSelector}"
CellEditTemplateSelector="{StaticResource PropertyValueEditTemplateSelector}" />
</telerik:RadGridView.Columns>
</telerik:RadGridView>
Now, I know one way to make this sample work, is just to remove the EnumTemplate
from propertyValueTemplateSelector (Normal), It will work, but I have other types I want to
display differently in edit and normal mode.
Appreciate for any help.