解决方法
如果您不想使用DatagridTemplateColumn,则可以更改
DataGridTextColumn.EditingElementStyle
并在那里设置TextBox.MaxLength:
<DataGridTextColumn Binding="{Binding Path=SellingPrice,UpdateSourceTrigger=PropertyChanged}"> <DataGridTextColumn.EditingElementStyle> <Style TargetType="{x:Type TextBox}"> <Setter Property="MaxLength" Value="10"/> </Style> </DataGridTextColumn.EditingElementStyle> </DataGridTextColumn>