I've put a RadMaskedNumericInput control onto window. To that I wanted to add validation. Here's the custom class I came up with:
and here's the XAML:
This all works fine.
In testing I discovered that if I put in some invalid numeric data, then I'll get a gold border and a popup message. Is that color standard with the RadMaskedNumericInput? Can that be styled?
xxx
public class ByteValidation : ValidationRule{ private byte min = 0; private byte max = byte.MaxValue; //The Minimum and Maximum values are there to restrict how low and how high the //stored value can be. public byte Minimum { get { return min; } set { min = value; } } public byte Maximum { get { return max; } set { max = value; } } public string ErrorMessage { get; set; } public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo) { if (value == null) { return new ValidationResult(true, null); } byte tmp; try { double dTmp = (double)value; tmp = (byte)dTmp; } catch (Exception) { return new ValidationResult(false, "Invalid value"); } if (tmp < min || tmp > max) { return new ValidationResult(false, ErrorMessage); } return new ValidationResult(true, null); }}and here's the XAML:
<telerik:RadMaskedNumericInput Mask="##" Margin="550,0,0,0" Grid.Row="1" FontSize="16" VerticalAlignment="Bottom" FontFamily="Century Gothic"> <telerik:RadMaskedNumericInput.Value> <Binding Path="DaysPaidLast30"> <Binding.ValidationRules> <local:ByteValidation Minimum="0" Maximum="30" ErrorMessage="Value must be between 0 and 30." /> </Binding.ValidationRules> </Binding> </telerik:RadMaskedNumericInput.Value></telerik:RadMaskedNumericInput>This all works fine.
In testing I discovered that if I put in some invalid numeric data, then I'll get a gold border and a popup message. Is that color standard with the RadMaskedNumericInput? Can that be styled?
xxx