Combine CellEditingTemplate CellTemplateSelector DataGrid

1.6k views Asked by At

I would like to apply CellTemplateSelector to a CellEditingTemplate. Can they be combined?

This is them separate

         <DataGridTemplateColumn x:Name="dateScheduledColumn" Header="Date Scheduled" Width="125">
            <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Path= DateScheduled, StringFormat=\{0:d\}}" />
                </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
            <DataGridTemplateColumn.CellEditingTemplate>
                <DataTemplate>
                    <DatePicker SelectedDate="{Binding Path=DateScheduled, Mode=TwoWay,
                        ValidatesOnExceptions=true, NotifyOnValidationError=true}" />
                </DataTemplate>
            </DataGridTemplateColumn.CellEditingTemplate>
        </DataGridTemplateColumn>
        <DataGridTemplateColumn Header="Grade">
            <DataGridTemplateColumn.CellTemplateSelector>
                <local:GradeTemplateSelector
        PassedTemplate="{StaticResource PassedTemplate}"
        FailedTemplate="{StaticResource FailedTemplate}"/>
            </DataGridTemplateColumn.CellTemplateSelector>
        </DataGridTemplateColumn>

If I try this I get a syntax error

    <DataGridTemplateColumn.CellEditingTemplate>
           <DataGridTemplateColumn.CellTemplateSelector>
1

There are 1 answers

1
Nikolay On BEST ANSWER

Just use DataGridTemplateColumn.CellEditingTemplateSelector