Posts

Showing posts with the label entry

[Xamarin Forms] Entry with rounded borders in your app

Image
Entry with rounded borders in your app (Xamarin Forms, NET MAUI) I know for some people it will be obvious, but I always seepeople asking how to make a custom Entry control with rounded borders...  To add rounded corners globally to Entry controls in a Xamarin Forms or .NET MAUI application, you can define a Style in the App.xaml (or Styles.xaml for .NET MAUI). This style will automatically apply to all Entry controls in your app, saving you from having to manually style each one. Example Define the global style in App.xaml : <Application.Resources> <ResourceDictionary> <Style TargetType="Entry"> <Setter Property="BackgroundColor" Value="White"/> <Setter Property="TextColor" Value="Black"/> <Setter Property="CornerRadius" Value="10"/> <Setter Property="HeightRequest" Value="50"/>

[Xamarin Forms] Custom bottom bordered entry (iOS & Android)

Image
Custom entry with renderers For my Xamarin Forms project I needed to render an 'Entry' control with a bottom border of a specific color. There are several possibilities but I will show you mine. For that, I used renderers. iOS one is particularly not trivial. The wished result look like that: iOS Renderer [assembly: ExportRenderer(typeof(ExtDatePicker), typeof(ExtDatePickerRenderer))] namespace MyCompany.iOS.Renderers { public class ExtDatePickerRenderer : DatePickerRenderer { protected override void OnElementChanged(ElementChangedEventArgs<DatePicker> e) { base.OnElementChanged(e); // Need to connect to Sizechanged event because first render time, Entry has no size (-1). if (e.NewElement != null) e.NewElement.SizeChanged += (obj, args) => { var xamEl = obj as DatePicker; if (xamEl == null) ret