Xamarin Form Project
BorderlessEntryWithDoneButton.cs
BorderlessEntryWithDoneButton.cs
using System; using System.Collections.Generic; using System.Text; using Xamarin.Forms; namespace TestApp.Renderer { public class BorderlessEntryWithDoneButton : Entry { } }Xamarin iOS Project
BorderlessEntryRendererWithDoneButton.cs
using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Text; using Foundation; using TestApp.iOS.CustomRenderers; using TestApp.Renderer; using UIKit; using Xamarin.Forms; using Xamarin.Forms.Platform.iOS; [assembly: ExportRenderer(typeof(BorderlessEntryWithDoneButton), typeof(BorderlessEntryRendererWithDoneButton))] namespace TestApp.iOS.CustomRenderers { public class BorderlessEntryRendererWithDoneButton : EntryRenderer { protected override void OnElementChanged(ElementChangedEventArgs<Entry> e) { base.OnElementChanged(e); if (Control != null && Element != null) { Control.BackgroundColor = Xamarin.Forms.Color.Transparent.ToUIColor(); Control.Layer.BackgroundColor = Xamarin.Forms.Color.Transparent.ToCGColor(); Control.BorderStyle = UITextBorderStyle.None; this.AddDoneButton(); } } protected void AddDoneButton() { var toolbar = new UIToolbar(new RectangleF(0.0f, 0.0f, 50.0f, 44.0f)); toolbar.BackgroundColor = UIColor.LightGray; var doneButton = new UIBarButtonItem(UIBarButtonSystemItem.Done, delegate { this.Control.ResignFirstResponder(); var baseEntry = this.Element.GetType(); ((IEntryController)Element).SendCompleted(); }); toolbar.Items = new UIBarButtonItem[] { new UIBarButtonItem (UIBarButtonSystemItem.FlexibleSpace), doneButton }; this.Control.InputAccessoryView = toolbar; } } }
Implementations
<renderer:BorderlessEntryWithDoneButton VerticalOptions="Center" Text="{Binding Title}" Placeholder="Event Name" " />
Great blog with good information.
ReplyDeleteXamarin Training in Chennai
Xamarin Online Training
Xamarin Training in Bangalore
Nice blog keep posting.
ReplyDeletePythin institute in hyderabad