So I have a XamDataGrid
with a percent field.
<igWPF:XamDataGrid DataSource="{Binding Data}" DataValueChanged="XamDataGrid_DataValueChanged">
<igWPF:XamDataGrid.FieldLayoutSettings>
<igWPF:FieldLayoutSettings AutoGenerateFields="False" AllowAddNew="False" AddNewRecordLocation="OnBottomFixed" />
</igWPF:XamDataGrid.FieldLayoutSettings>
<igWPF:XamDataGrid.FieldLayouts>
<igWPF:FieldLayout>
<igWPF:Field Name="Percent" />
</igWPF:FieldLayout>
</igWPF:XamDataGrid.FieldLayouts>
</igWPF:XamDataGrid>
I need to set the percent field to have 100 as a maximum value. How can I do so?
You can use a numeric field, i.e. int
/ Int32
and set the field editor type to XamNumericEditor
. Then, you can define a ValueConstraint
that specifies the minimum and maximum values.
<igWPF:XamDataGrid DataSource="{Binding Data}" DataValueChanged="XamDataGrid_DataValueChanged">
<igWPF:XamDataGrid.FieldLayoutSettings>
<igWPF:FieldLayoutSettings AutoGenerateFields="False" AllowAddNew="False" AddNewRecordLocation="OnBottomFixed" />
</igWPF:XamDataGrid.FieldLayoutSettings>
<igWPF:XamDataGrid.FieldLayouts>
<igWPF:FieldLayout>
<igWPF:Field Name="Percent" DataType="{x:Type sys:Int32}" BindingType="Unbound">
<igWPF:Field.Settings>
<igWPF:FieldSettings EditorType="{x:Type igEditors:XamNumericEditor}">
<igWPF:FieldSettings.EditorStyle>
<Style TargetType="{x:Type igEditors:XamNumericEditor}">
<Setter Property="ValueConstraint">
<Setter.Value>
<igEditors:ValueConstraint MinInclusive="0" MaxInclusive="100" />
</Setter.Value>
</Setter>
</Style>
</igWPF:FieldSettings.EditorStyle>
</igWPF:FieldSettings>
</igWPF:Field.Settings>
</igWPF:Field>
</igWPF:FieldLayout>
</igWPF:XamDataGrid.FieldLayouts>
</igWPF:XamDataGrid>
For more information, see the code example for Configuring XamNumericEditor and others: