How can I limit WPF DataGridTextColumn
Text to max length of 10 characters.
I don't want to use DatagridTemplateColumn
, because it has memory leak problems.
Also the field is bound to a data entity model.
If you don't want to use DatagridTemplateColumn
then you can change DataGridTextColumn.EditingElementStyle
and set TextBox.MaxLength
there:
<DataGridTextColumn Binding="{Binding Path=SellingPrice, UpdateSourceTrigger=PropertyChanged}">
<DataGridTextColumn.EditingElementStyle>
<Style TargetType="{x:Type TextBox}">
<Setter Property="MaxLength" Value="10"/>
</Style>
</DataGridTextColumn.EditingElementStyle>
</DataGridTextColumn>