How to create a borderless Xamarin.Forms numeric control (SfNumericTextBox)
This KB article explains how to create a Syncfusion SfNumericTextBox without having its border as shown in the following image.
It has been achieved by using the custom renderer of Xamarin.Forms SfNumericTextBox with the platform-specific as shown in the following code changes.
Create a CustomNumericTextBox class, which is inherited from the SfNumericTextBox.
[C#]
public class CustomNumericTextBox: SfNumericTextBox { }
Control initialization with the custom numericTextBox class.
[XAML]
<borderless_textbox:CustomNumericTextBox Value="123" HorizontalOptions="Center" VerticalOptions="Center" />
Android
It has been achieved by setting the null to the background native numeric control as shown in the following code sample.
[C#]
protected override void OnElementChanged(ElementChangedEventArgs<SfNumericTextBox> e) { base.OnElementChanged(e); if (Control != null) { Control.Background = null; } }
iOS
To achieve the same in the iOS, set ‘0’ as a border width of the native control.
[C#]
protected override void OnElementChanged(ElementChangedEventArgs<SfNumericTextBox> e) { base.OnElementChanged(e); if (Control != null) { Control.BorderStyle = UIKit.UITextBorderStyle.None; Control.Layer.CornerRadius = 0f; Control.Layer.BorderColor = Color.Transparent.ToCGColor(); Control.Layer.BorderWidth = 0; } }
UWP
Set ‘0’ as a border thickness as shown in the following code sample.
[C#]
protected override void OnElementChanged(ElementChangedEventArgs<SfNumericTextBox> e) { base.OnElementChanged(e); if (Control != null) { Control.BorderThickness = new Windows.UI.Xaml.Thickness(0); } }
See also
How to set the text color, Background color, watermark color, border color in Xamarin Numeric Entry (SfNumericTextBox)
How to set the maximum number of Decimal Digits in Xamarin Numeric Entry (SfNumericTextBox)
How to set the range support in Xamarin Numeric Entry (SfNumericTextBox)
How to provide selection support in Xamarin Numeric Entry (SfNumericTextBox)
How to provide Return Type in Xamarin Numeric Entry (SfNumericTextBox)