NumberBox with DecimalPlaces>0 configured does not allow keyboard input
See original GitHub issueDescribe the bug
I placed a NumberBox on my page as so:
<ui:NumberBox Min="0.0" Margin="0,0,0,5" PlaceholderEnabled="False" SpinButtonsEnabled="False" InputScope="CurrencyAmount" Step="0.01" Value="0" />
However there does not seem to be anyway to type number into this field, I can only make adjustments to it using the Up/Down arrowKeys (or if enable “SpinButtonsEnabled” the buttons adjust it by my Step Amount). Im not sure if there is something I am missing, however i would expect this to work similarly to how a normal Numberbox with DecimalPlaced=“0” works, but with add functionality to also accept a single decimal in the input.
*Note this may be a duplicate of #269 however that discussion seems to be more geared towards the Chinese Character issue
To Reproduce
Add a ui:NumberBox field into your page, and set the Decimal Places to 2 (default) Add another ui:NumberBox field into your page and set the Decimal Places to 0
The first ui:NumberBox will not allow you to type into it, while the second ui:NumberBox will allow number inputs
Expected behavior
ui:NumberBox with 2 Decimal Places should allow number input similar to how the input works with DecimalPlaces value set to 0, however a single decimal and the number of DecimalPlaces it is configured for should also be able to be typed in.
Screenshots
No response
OS version
Windows 11
.NET version
.NET 6.0
WPF-UI NuGet version
2.0.3
Additional context
This also seems to be true when running the Demo. If you go into the Input section, then scroll to the NumberBox section, and look at the decimal example, you cannot type anything into that field, you may only use arrowKeys or the SpinButtons
Issue Analytics
- State:
- Created 9 months ago
- Reactions:1
- Comments:5
I haven’t tried this extensively, but seems to get the job done for the most part if you need to use decimals. It’s a bit lengthy. Make sure you set
IsReadOnly
andIsReadOnlyCaretVisible
toTrue
. This is necessary as it works as a workaround to disable the original behaviour.Probably some weird edge-cases still in there, but you should be able to add numbers via either digits or numpad as well as remove with backspace, delete and by selecting text.
I found a workaround to achieve the results i was looking for. It does not involve WPF UI however.
Note: Dont forget to add the Using statement to your helper class, Intellisense should help you with that if you do not know how.
Im still a noob at all this WPF stuff so there may be an easier way to accomplish this specifically, however this is how i managed to get what i needed. Source of this class can be found on StackOverflow