I need to accept only specific digits into a column in datagrid how can i handle it?
<DataGridTextColumn Binding="{Binding Path=SellingPrice, UpdateSourceTrigger=PropertyChanged}">
<DataGridTextColumn.EditingElementStyle>
<Style TargetType="{x:Type TextBox}">
<Setter Property="MaxLength" Value="10"/>
</Style>
</DataGridTextColumn.EditingElementStyle>
</DataGridTextColumn>
in above code i have given Value="10", I need to bind the value from ViewModel how can i do it
I'm not able to test this at the moment, but you may have to do this in your style:
<Style TargetType="{x:Type TextBox}">
<Setter Property="MaxLength" Value="{Binding Path=DataContext.MyMaxLength"/>
</Style>
Where MyMaxLength
is a property on your bound object.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.