如何在WPF数据网格单元格编辑模式下使用myCustomTextBox更改TextBox

问题描述 投票:-2回答:1

我需要在WPF数据网格单元编辑模式下使用TextBox更改默认的myCustomTextBox

例如:当用户双击一个单元格时,显示MyCustomControl而不是WPF TextBox。

谢谢。

c# wpf datagrid textbox edit
1个回答
0
投票

你可以使用cellediting模板like this在这里输入代码

  <DataGrid ItemsSource="{Binding}">
        <DataGrid.Resources>
            <DataTemplate x:Key="CellEditingTemplate">
                <local:myCustomTextBox Text="{Binding PropertyName}"/>
            </DataTemplate>
        </DataGrid.Resources>
        <DataGridTemplateColumn CellEditingTemplate="{StaticResource CellEditingTemplate}"/>
</DataGrid>
© www.soinside.com 2019 - 2024. All rights reserved.