Hello.
When I use a mask "{}{number:1-2}.##" in XamMaskedEditor, I expect first symbol can be "1" or "2". But I can input "0" as first symbol.
How can I exclude "0" as first symbol?
Hello Alexey,
Thank you for contacting Infragistics. You may use a regular expression to exclude zeros from being inputted on the editor.
eg.
<igEditors:XamMaskEditor.ValueConstraint> <igEditors:ValueConstraint RegexPattern="^-?(0\.\d*[1-9]\d*|[1-9]\d*(\.\d+)?)$"/> </igEditors:XamMaskEditor.ValueConstraint>
I tried to apply the solution. But it still does not work. I can input "0" as before.
<Style TargetType="{x:Type igDP:CellValuePresenter}" x:Key="NumberCell" >
<Setter Property="Template" >
<Setter.Value >
<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}" >
<presentationsEx:XamMaskedEditor Margin="16,8,8,8"
VerticalAlignment="Top"
HorizontalAlignment="Left"
Style="{StaticResource XamMaskedEditorStyle}"
Height="32"
PadChar="_"
DisplayMode="IncludeBoth"
Mask="{}{number:1-2}.##"
Text="{Binding Path=DataItem.OrderNumber, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"
Width="40"
InvalidValueBehavior="RetainValue">
<presentationsEx:XamMaskedEditor.ValueConstraint>
<editors:ValueConstraint RegexPattern="^[1-2]\.\d{2}$" />
</presentationsEx:XamMaskedEditor.ValueConstraint>
<i:Interaction.Triggers>
<i:EventTrigger EventName="TextChanged">
<i:InvokeCommandAction Command="{Binding Path=DataContext.CheckAllNumbersCommand, RelativeSource={RelativeSource AncestorType={x:Type igDP:XamDataGrid}}}" CommandParameter="{Binding DataItem}" />
</i:EventTrigger>
<i:EventTrigger EventName="EditModeStarted">
<ie:CallMethodAction MethodName="NumberCell_EditModeStarted" TargetObject="{Binding Path=DataContext, RelativeSource={RelativeSource AncestorType={x:Type igDP:XamDataGrid}}}" />
<i:EventTrigger EventName="LostFocus">
<ie:CallMethodAction MethodName="NumberCell_LostFocus" TargetObject="{Binding Path=DataContext, RelativeSource={RelativeSource AncestorType={x:Type igDP:XamDataGrid}}}" />
</i:Interaction.Triggers>
</presentationsEx:XamMaskedEditor>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>