DataGridTemplateColumn.CellEditingTemplate プロパティ

定義

編集モードのセルの内容を表示するために使用するテンプレートを取得または設定します。

public:
 property System::Windows::DataTemplate ^ CellEditingTemplate { System::Windows::DataTemplate ^ get(); void set(System::Windows::DataTemplate ^ value); };
public System.Windows.DataTemplate CellEditingTemplate { get; set; }
member this.CellEditingTemplate : System.Windows.DataTemplate with get, set
Public Property CellEditingTemplate As DataTemplate

プロパティ値

DataTemplate

編集モードのセルの内容を表示するときに使用するテンプレート。 登録済みの既定値は null です。 この値が何に影響されるかについては、DependencyProperty のトピックを参照してください。

次の例では、日付の列を CellEditingTemplate 表示および編集するためのデータを作成する方法を示します。

<Grid>
    <Grid.Resources>
        <!--DataTemplate for Published Date column defined in Grid.Resources.  PublishDate is a property on the ItemsSource of type DateTime -->
        <DataTemplate x:Key="DateTemplate" >
            <StackPanel Width="20" Height="30">
                <Border Background="LightBlue" BorderBrush="Black" BorderThickness="1">
                    <TextBlock Text="{Binding PublishDate, StringFormat={}{0:MMM}}" FontSize="8" HorizontalAlignment="Center" />
                </Border>
                <Border Background="White" BorderBrush="Black" BorderThickness="1">
                    <TextBlock Text="{Binding PublishDate, StringFormat={}{0:yyyy}}" FontSize="8" FontWeight="Bold" HorizontalAlignment="Center" />
                </Border>
            </StackPanel>
        </DataTemplate>
        <!--DataTemplate for the Published Date column when in edit mode. -->
        <DataTemplate x:Key="EditingDateTemplate">
            <DatePicker SelectedDate="{Binding PublishDate}"  />
        </DataTemplate>
    </Grid.Resources>
    <DataGrid Name="DG1" ItemsSource="{Binding}" AutoGenerateColumns="False" >
        <DataGrid.Columns>
            <!--Custom column that shows the published date-->
            <DataGridTemplateColumn Header="Publish Date" CellTemplate="{StaticResource DateTemplate}" CellEditingTemplate="{StaticResource EditingDateTemplate}" />
        </DataGrid.Columns>
    </DataGrid>
</Grid>

次の図は、前の XAML からの出力を示しています。

DataTemplate を使用した列

注釈

セル編集テンプレートは、編集モードの場合に列セルにコンテンツを表示する方法を定義します。 データ テンプレートの詳細については、「 データ テンプレートの概要 」および「 スタイルとテンプレート」を参照してください。

編集モードではないセルのテンプレートを定義するには、 CellTemplate.

適用対象

こちらもご覧ください