Hy,
I want to use SfNumericEntry in my App to enter decimal percent value like, for example in Xaml:
<VerticalStackLayout Margin="5">
<syncfusioncore:SfTextInputLayout
Hint="Insert percent value (%)">
<editors:SfNumericEntry Value="{Binding PercentValue, Mode=TwoWay}" CustomFormat="p2" UpDownPlacementMode="Inline" SmallChange="0.005" ShowClearButton="True" />
</syncfusioncore:SfTextInputLayout>
</VerticalStackLayout>
it works fine on android emulator but when run it on my Samsung S21 device I can't insert decimal point (or comma) and minus (I need to use also negative values).
I have found that this issue also is present in Xamarin Forms and below link offer a solution to workaround it:
I have tried to reproduce in Maui but SfNumeriEntry don't have a renderer.
What can I do?
Thanks Rolando
Hi Rolando Tonin,
We recommend that you set the keyboard to numeric entry in size changed event as in the code snippet below to resolve the reported issue. We have created the sample based on this and attached it for your reference.
Please refer to the below code snippet for this
| public MainPage() { InitializeComponent(); this.BindingContext = new ViewModel(); this.SizeChanged += MainPage_SizeChanged; } private void MainPage_SizeChanged(object sender, EventArgs e) { // Change the keyboard in numeric entry if ((numericEntry.Children[0] as Entry) != null) { (numericEntry.Children[0] as Entry).Keyboard = Keyboard.Telephone; } } |
Hy Jeya,
this workaround seems to work right on Samsung phone devices. To solve it so I don't repeat above code on every page that use SfnumericEntry, I could create a new control, derived from SfNumericEntry and manage the event OnSizeChanged.
what do you think about it?
thanks a lot.
Rolando Tonin
Hi Rolando,
We have reviewed your query and would like to inform you that you can utilize a custom control derived from SfNumericEntry. This custom control allows you to handle the SizeChanged event method, thereby avoiding the need to duplicate code on every page where you wish to employ the SfNumericEntry control in .NET MAUI. We have prepared a sample based on your requirements. Kindly review the attached sample and let us know the details.
Code Snippet :
|
public class SfNumericCustom : SfNumericEntry { public SfNumericCustom() {
this.BackgroundColor = Colors.Transparent; this.SizeChanged += SfNumericCustom_SizeChanged; }
private void SfNumericCustom_SizeChanged(object sender, EventArgs e) { if ((this.Children[0] as Entry) != null) { (this.Children[0] as Entry).Keyboard = Keyboard.Telephone; } }
} |
Regards,
Ahamed Ali Nishad.
Hi,
I also have this problem, and setting the keyboard to "telephone" as per the custom control does enable me to enter a minus sign on Samsung phones (with a lot of fiddling).
However it looks very strange in my app (a math equation solver)!
Are you looking at fixing the underlying problem so I can use a "numeric" keyboard on a Samsung device?
The minus sign work fine on Samsung phones on other apps (e.g. fncalculator.com) ...
Many thanks,
David Speak.
Hi David,
We have reviewed your query and would like to inform you that it is not related to the Syncfusion issue. The keyboard issue also occurs when using controls such as Entry and Editor in .NET MAUI. Since it is the native Android keyboard, the layout changes based on the operating system. Therefore, it is not possible to fix it at our end. Currently, we have one workaround as suggested in the previous update.
Regards,
Ahamed Ali Nishad.
Hi Ahamed,
Sorry to bother you again, but I think we may be discussing a different problem.
Using VS2022 latest, testing on a Samsung S20 …
The number keyboard is shown correctly when using a SfNumericEntry control, and when using a maui Entry control with keyboard set to numeric.
On the Entry control, when on the first character, I can single click the combined "." and "-" keyboard button and the control has a decimal point. A double click changes it to a minus sign so I can enter negative numbers.
On the SfNumericEntry control, when on the first character, I can single click the combined "." and "-" keyboard button and the control has a decimal point. A double click does not change to a minus sign so I cannot enter negative numbers.
<Label Text="Maui Entry: can enter -1 OK"/>
<Entry Keyboard="Numeric"/>
<Label Text="SfNumericEntry: cannot enter -1 ??"/>
<editors:SfNumericEntry />
I've attached a simple sample and screenshot for your info.
If it works with a Maui Entry control, couldn't it work with a SfNumericControl ?
Many thanks again,
David.
Sorry didn't know I can only upload one file per post - screenshot attached …
Hi David Speak,
We have already included the fix for the reported issue "Cannot enter minus sign initially in SfNumericEntry on Samsung device" in our earlier weekly release. Please install the latest NuGet, which is available for download (NuGet). We thank you for your support and appreciate your patience in waiting for this update. Please get in touch with us if you require any further assistance.
Regards,
Prithis I.