Introduction:
In this article, we can learn how to create entry without border using custom renderer
Description:
In Xamarin.Forms, there is no way to set border less properties to Entry in Xaml. Alternately we have to use custom renderers in platform specific projects like below
Let's create render class in Android project
Let's create render class in iOS project
In this article, we can learn how to create entry without border using custom renderer
Description:
In Xamarin.Forms, there is no way to set border less properties to Entry in Xaml. Alternately we have to use custom renderers in platform specific projects like below
Let's create render class in Android project
- [assembly: ExportRenderer(typeof(Entry), typeof(BorderlessEntryRenderer))]
- namespace FirstApp.Android.Renderers
- {
- public class BorderlessEntryRenderer : EntryRenderer
- {
- protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
- {
- base.OnElementChanged(e);
- if (e.OldElement == null)
- {
- Control.Background = null;
- }
- }
- }
- }
Let's create render class in iOS project
- [assembly: ExportRenderer(typeof(Entry), typeof(BorderlessEntryRenderer))]
- namespace FirstApp.iOS.Renderers
- {
- public class BorderlessEntryRenderer : EntryRenderer
- {
- protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- base.OnElementPropertyChanged(sender, e);
- Control.Layer.BorderWidth = 0;
- Control.BorderStyle = UITextBorderStyle.None;
- }
- }
- }
FeedBack Note: Please share your thoughts, what you think about this post, Is this post really helpful for you? I always welcome if you drop comments on this post and it would be impressive.
No comments:
Post a Comment