I want to implement:
If ID ==0 , in the Region column, the control should be comboBox. So that I can select from a list.
if ID != 0, in the Region column, the control should be TextBlock.
I used templateSelector and DataTemplate. The TextBlock controls work fine. But for some reason, the ComboBox doesn't work.
<telerik:RadGridView.Columns>
<telerik:GridViewColumn CellTemplateSelector="{StaticResource commandCellSelector}" Width="110"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding RegionName, Mode=TwoWay}" Header="Region" Width="180" CellTemplateSelector="{StaticResource regionCellSelector}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding DivisionName, Mode=TwoWay}" Header="Division" Width="180"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding SubDivisionName, Mode=TwoWay}" Header="SubDivision" Width="180"/>
</telerik:RadGridView.Columns>
<DataTemplate x:Key="RegionEditTemplate">
<TextBlock Text="{Binding RegionName, Mode=TwoWay}" />
</DataTemplate>
<DataTemplate x:Key="RegionAddNewTemplate">
<ComboBox ItemsSource="{Binding RegionSearchList, Source={StaticResource ViewModel}}"DisplayMemberPath="Name" SelectedValuePath="ID" SelectedValue="{Binding RegionID}"/>
</DataTemplate>
<templateSelector:ManageWorkAreaRegionSelector x:Name="regionCellSelector" RegionEditTemplate="{StaticResource RegionEditTemplate}" RegionAddNewTemplate="{StaticResource RegionAddNewTemplate}"/>
If ID ==0 , in the Region column, the control should be comboBox. So that I can select from a list.
if ID != 0, in the Region column, the control should be TextBlock.
I used templateSelector and DataTemplate. The TextBlock controls work fine. But for some reason, the ComboBox doesn't work.
<telerik:RadGridView.Columns>
<telerik:GridViewColumn CellTemplateSelector="{StaticResource commandCellSelector}" Width="110"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding RegionName, Mode=TwoWay}" Header="Region" Width="180" CellTemplateSelector="{StaticResource regionCellSelector}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding DivisionName, Mode=TwoWay}" Header="Division" Width="180"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding SubDivisionName, Mode=TwoWay}" Header="SubDivision" Width="180"/>
</telerik:RadGridView.Columns>
<DataTemplate x:Key="RegionEditTemplate">
<TextBlock Text="{Binding RegionName, Mode=TwoWay}" />
</DataTemplate>
<DataTemplate x:Key="RegionAddNewTemplate">
<ComboBox ItemsSource="{Binding RegionSearchList, Source={StaticResource ViewModel}}"DisplayMemberPath="Name" SelectedValuePath="ID" SelectedValue="{Binding RegionID}"/>
</DataTemplate>
<templateSelector:ManageWorkAreaRegionSelector x:Name="regionCellSelector" RegionEditTemplate="{StaticResource RegionEditTemplate}" RegionAddNewTemplate="{StaticResource RegionAddNewTemplate}"/>