我是WPF的新手,很确定我在主题行中没有正确的问题,无论如何,我试图将MaxLength设置为DataGridTextColumn,但是当我这样做时,我被告知“属性” “ EditingElementStyle”被设置了多次”,我可以看到在第二行代码中有EditingElementyStyle =“ {StaticResource TextboxToUpper}”,但我想知道如何向其中添加MaxLength?
<DataGridTextColumn Header="Comment" Binding="{Binding Comment, UpdateSourceTrigger=PropertyChanged}" Width="200" CellStyle="
{StaticResource EditableDataGridCell}" EditingElementStyle="{StaticResource TextBoxToUpper}">
<DataGridTextColumn.EditingElementStyle>
<Style TargetType="TextBlock">
<Setter Property="MaxLength" Value="255"/>
</Style>
</DataGridTextColumn.EditingElementStyle>
</DataGridTextColumn>
答案 0 :(得分:0)
只需使用Style.BasedOn
<DataGridTextColumn Header="Comment" Binding="{Binding Comment, UpdateSourceTrigger=PropertyChanged}" Width="200" CellStyle="{StaticResource EditableDataGridCell}">
<DataGridTextColumn.EditingElementStyle >
<Style TargetType="TextBox" BasedOn="{StaticResource TextBoxToUpper}">
<Setter Property="MaxLength" Value="255"/>
</Style>
</DataGridTextColumn.EditingElementStyle>
</DataGridTextColumn>