-
Notifications
You must be signed in to change notification settings - Fork 460
Closed
Labels
bugSomething isn't workingSomething isn't workingneeds reproductionstaleThe author has not responded in over 30 daysThe author has not responded in over 30 daysunverified
Description
Is there an existing issue for this?
- I have searched the existing issues
Did you read the "Reporting a bug" section on Contributing file?
- I have read the "Reporting a bug" section on Contributing file: https://github.com/CommunityToolkit/Maui/blob/main/CONTRIBUTING.md#reporting-a-bug
Current Behavior
When attaching NumericValidationBehavior to an input element (e.g., Entry) and binding it to a nullable numeric property (decimal?, int?, etc.), the application crashes if the property is null.
Error message:
Value cannot be null.
If the property is initialized with a non-null value, everything works fine. This effectively prevents the use of nullable numeric properties in binding contexts with NumericValidationBehavior.
Expected Behavior
The behavior should allow null values when binding to nullable numeric types, without throwing an exception.
Steps To Reproduce
- Create a ViewModel with a nullable numeric property:
public decimal? Amount { get; set; }
- Bind an Entry to the property with NumericValidationBehavior:
<Entry Text="{Binding Amount}">
<Entry.Behaviors>
<toolkit:NumericValidationBehavior />
</Entry.Behaviors>
</Entry>
- Run the app while the property is null.
Link to public reproduction project repository
n/a
Environment
- .NET MAUI CommunityToolkit:
- OS:
- .NET MAUI:
Anything else?
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingneeds reproductionstaleThe author has not responded in over 30 daysThe author has not responded in over 30 daysunverified