Skip to content

Entry bound to a double casts values too early, preventing small negative decimal entries #30181

@TrueMoniker

Description

@TrueMoniker

Description

When using a numeric entry bound to a double, with a negative decimal entry, any value equivalent to 0 will convert to 0, which makes it difficult to type small numbers. I noticed this behavior particularly while writing -0.01.

IE while I'm typing -0.01 in an entry that is bound to a double, I type -0.0 and then 1. However the -0.0 becomes 0. So I end up typing 01, which is converted to 1.

Steps to Reproduce

  1. Simplest is to run the linked example repo.

  1. Alternatively, create a new app by choosing Create a File > New .NET MAUI App
  2. Add a 'Entry' with a double bound to the text, like so:
    <Entry Keyboard="Numeric" 
                Text="{Binding NumericValue}"/>
  3. Add a bindable viewmodel by following the Data binding and MVVM
    tutorial.
  4. Add a bindable Numeric value to your page. I'm using the ObservableProperty attribute to make the binding simpler
    [ObservableProperty]
    double? numericValue;
    
  5. Run your app
  6. Type -0.01 in your entry

Expected outcome: The value -0.01 is displayed
Actual outcome: The value 1 is displayed

Link to public reproduction project repository

https://github.com/TrueMoniker/Maui_BugDemo_EntryWithDouble

Version with bug

9.0.0 GA

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

No response

Affected platforms

iOS, Android

Affected platform versions

Unknown

Did you find any workaround?

Yes. In the linked repo I provide a work around control in NumericEntry.cs

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions