diff --git a/demo/Ursa.Demo/Pages/FormDemo.axaml b/demo/Ursa.Demo/Pages/FormDemo.axaml
index 288392a..5d63392 100644
--- a/demo/Ursa.Demo/Pages/FormDemo.axaml
+++ b/demo/Ursa.Demo/Pages/FormDemo.axaml
@@ -41,6 +41,7 @@
Width="300"
u:FormItem.Label="Email"
Text="{Binding Email}" />
+
diff --git a/demo/Ursa.Demo/ViewModels/FormDemoViewModel.cs b/demo/Ursa.Demo/ViewModels/FormDemoViewModel.cs
index 5f706a0..45f6ba9 100644
--- a/demo/Ursa.Demo/ViewModels/FormDemoViewModel.cs
+++ b/demo/Ursa.Demo/ViewModels/FormDemoViewModel.cs
@@ -24,6 +24,14 @@ public partial class DataModel : ObservableObject
get=>_name;
set => SetProperty(ref _name, value);
}
+
+ private double _number;
+ [Range(0.0, 10.0)]
+ public double Number
+ {
+ get => _number;
+ set => SetProperty(ref _number, value);
+ }
private string _email;
diff --git a/src/Ursa/Controls/NumericUpDown/NumericUpDownBase.cs b/src/Ursa/Controls/NumericUpDown/NumericUpDownBase.cs
index 5d41aaa..fe07226 100644
--- a/src/Ursa/Controls/NumericUpDown/NumericUpDownBase.cs
+++ b/src/Ursa/Controls/NumericUpDown/NumericUpDownBase.cs
@@ -380,7 +380,7 @@ public abstract class NumericUpDownBase : NumericUpDown where T : struct, ICo
}
public static readonly StyledProperty ValueProperty = AvaloniaProperty.Register, T?>(
- nameof(Value), defaultBindingMode: BindingMode.TwoWay);
+ nameof(Value), defaultBindingMode: BindingMode.TwoWay, enableDataValidation: true);
public T? Value
{
@@ -485,6 +485,15 @@ public abstract class NumericUpDownBase : NumericUpDown where T : struct, ICo
set => this.SetValue(CommandParameterProperty, value);
}
+ protected override void UpdateDataValidation(AvaloniaProperty property, BindingValueType state, Exception? error)
+ {
+ if (property == ValueProperty)
+ {
+ DataValidationErrors.SetError(this, error);
+ }
+
+ }
+
private void InvokeCommand(object? cp)
{
if (this.Command != null && this.Command.CanExecute(cp))