助けてくれてありがとう。コードからcelleditingtemplate(datatemplate)にあるusercontrolのバインディングを設定する必要があります。つまり、同じデータテンプレートを指すcelleditingtemplateを持つ2つのdatatemplate列を持つグリッドがあります。ユーザーが編集しているセルに基づいて、celleditingtemplateのバインドを動的に変更する必要があります。どんな助けでも大歓迎です。
ありがとう
これがサンプルコードです。これは別のリソースファイルにあります
<DataTemplate x:Key="TextCellEditingTemplate">
<UserControls:TextControl HorizontalAlignment="Left"/>
</DataTemplate>
これは、バインディングを設定する必要があるページの背後にあるコードです。
private void datagrid_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
{
var row = e.Row;
var column = e.Column as DataGridTemplateColumn;
if (column != null)
{
//sets the template based on the dataelement
column.CellEditingTemplate = UserControlFactory.GetCellEditingTemplate(((row.DataContext) as CollectionData).DataElement);
}
}