Replies: 5 comments 9 replies
-
Add this property to your Entry: Keyboard="Numeric" |
Beta Was this translation helpful? Give feedback.
-
If it isn't possible to limit what characters are entered in an Entry control on Windows using .NET MAUI since it is using TextBox from WinUI is it possible to change the Entry control to use NumberBox from WinUI if the platform is Windows? |
Beta Was this translation helpful? Give feedback.
-
I'm still looking for help if anyone has any ideas? |
Beta Was this translation helpful? Give feedback.
-
i have been look for a good way to do this for a while ... the following works but can definitely be improved `
` `
` |
Beta Was this translation helpful? Give feedback.
-
@MattBDev I know you asked this long ago, but here's my approach to solving this problem. I am listening to TextChanged events on the Entry control and if the new value contains non-digits, I clean them from the value and set the modified value on the Entry. Here's an example with an entry control for entering minutes (must be integer): In page constructor:
And the event handler:
If you bind the entry to an integer property, like I have, you will get unhandled exceptions because the entry will try to assign the value before your handler is triggered. You can bind to an intermediate string-typed property to avoid this. |
Beta Was this translation helpful? Give feedback.
-
I was wondering if it was possible to prevent non-numeric characters from being input in an Entry control? If that isn't possible, I want to delete text that the user entered that is invalid when the control looses focus, the completed event, or the return command is fired. I have been looking for an answer but I haven't been able to find one. As far as I can tell, it isn't possible to cancel the TextChanged event. Can anyone point me on the right track or provide an answer?
Beta Was this translation helpful? Give feedback.
All reactions