More Group Sites
Education Books
School Rankings
Jobless Net
Better Home
Welcome Guest! To enable all features please Login or Register.



Go to last post Go to first unread
#1 Posted : Friday, March 29, 2019 7:33:55 AM(UTC)

Rank: Administration


Groups: AcademicCoachingSchool, admin, Administration, BookSeller, CatholicSchool, CoachingAdult, CoachingProfessional, CoachingSports, ExtraCurriculumCoaching, IndependentSchool, Moderator, MusicTeacher, PrivateSchool, PublicSchool, SelectiveSchool, tutor
Joined: 11/23/2008(UTC)
Posts: 522

Xamarin forms Entry control with clear button by ClearEntryEffect

Xamarin forms Entry control doesn't have the clear future built-in. However, Depechie has provided a solution, see Xamarin forms – Clear entry control effect. You can also his source code in github. You just need to copy the Effects cs files into your shared, Android and iOS projects. You may need to change the namespace accordingly. FYI: fundamentals of creating effects on Xamarin forms

Please note that the effect not only works for Entry control but also Editor control, which is a multi-line text editor.

I followed Depechie's article. I got ClearEntryEffect working on Android. But I have the following issues with the feature on iOS:

PlatformEffect fails to attach to Page elements in iOS


The issue should have been fixed long time ago.

I use Xamarin.forms, but I still have the same problem.

For iOS, I have to add an EntryRenderer EntryWithClearButonRenderer in iOS project, and a derived Entry control EntryWithClearButon, which is placed in the Renders folder in shared project.

In this way I got it working. But this just a workaround because PlatformEffect doesn't call OnAttached in iOS even though I have the ClearEentryEffect in xaml of the page.

See my code below

using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;

[assembly: ExportRenderer(typeof(EntryWithClearButon), typeof(EntryWithClearButonRenderer))]

namespace tecommobile.iOS
    public class EntryWithClearButonRenderer : EntryRenderer
        protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
            if (Control != null)
                Control.ClearButtonMode = UITextFieldViewMode.WhileEditing;

    public class EntryWithClearButon : Entry
        public EntryWithClearButon()

        public string EntryText { get; set; }

Edited by user Friday, March 29, 2019 7:39:24 AM(UTC)  | Reason: Not specified

Rss Feed  Atom Feed
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.