Hi, I am using a XamDataGrid and inside I have a column of SliceGoal sizes which values can only be integers. Currently I am using XamNumericEditor which forces the user to write only integers. How can I also add a constrain that the value would only be a positive number? Thanks, Alon
<dp:UnboundField Name="SliceGoal"
Width="Auto"
Label="Slice Goal Size"
BindingPath="Model.SliceGoal"
BindingMode="TwoWay"
DataType="{x:Type System:Int64}">
<dp:UnboundField.Settings>
<dp:FieldSettings>
<dp:FieldSettings.EditorStyle>
<Style TargetType="{x:Type Editors:XamNumericEditor}">
<Setter Property="IsReadOnly" Value="{Binding RelativeSource={RelativeSource Mode=FindAncestor,
AncestorType={x:Type dp:CellValuePresenter}}, Path=Record.DataItem.Model.IsSliceGoalReadOnly}" />
</Style>
</dp:FieldSettings.EditorStyle>
</dp:FieldSettings>
</dp:UnboundField.Settings>
</dp:UnboundField>
How can we also restrict zero also?
You should add one more setter in editor's style:
<Setter Property="Mask" Value="nnnnn" />
Regards,
Anastas
where exactly in my code (shown above) do I insert the Mask = "nnnnn" ?
Hi,
You can use XamNumeric's Mask property like this:
Mask="nnnnn"
Or use the ValueType property, and set it to
ValueType="{x:Type sys:UInt64}"
If you choose the second option(the ValueType), I guess you should set the FieldSettings' EditAsType also to "UInt64".