Forum Xamarin.Forms

[Material] TextInputLayout Renderer (Floating Labels)

ChaseFlorellChaseFlorell CAInsider, University mod
edited March 2017 in Xamarin.Forms

EDIT:

I've now written a control for iOS and Android (also includes an AutoComplete/ComboBox)

Install-Package Xfx.Controls

Or the source: https://github.com/XamFormsExtended/Xfx.Controls

ORIGINAL POST:

Just thought I'd throw this out there. If you want floating labels on your Entry (as found here (by JamesMontemagno)), I've thrown together a custom renderer that extends Entry.

note: this requires the AppCompat stuff to be enabled in your Android App.

First you want to create an axml view and drop it in your /Resources/layout directory.

TextInputLayout.axml

<!-- NOTE: MyAppCompatTheme is important - it MUST apply an AppCompat theme of some sort -->
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.TextInputLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:id="@+id/textInputLayout"
  android:theme="@style/MyAppCompatTheme">
  <EditText
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:singleLine="true" />
</android.support.design.widget.TextInputLayout>

From there, just drop this renderer into your Droid Renderers directory (wherever that lives).

MaterialEntryRenderer_Droid.cs

using System;
using System.ComponentModel;
using Android.Content;
using Android.Support.Design.Widget;
using Android.Text;
using Android.Views;
using Android.Views.InputMethods;
using Android.Widget;
using MyApp.Droid.Extensions;
using MyApp.Droid.Renderers;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
using Application = Android.App.Application;
using TextChangedEventArgs = Android.Text.TextChangedEventArgs;
[assembly: ExportRenderer(typeof(MaterialEntry), typeof(MaterialEntryRenderer_Droid))]

namespace MyApp.Droid.Renderers
{
    public class MaterialEntryRenderer_Droid : Xamarin.Forms.Platform.Android.AppCompat.ViewRenderer<MaterialEntry, TextInputLayout>
    {
        private EditText _defaultEditTextForValues;
        private bool _preventTextLoop;

        protected override void OnElementChanged(ElementChangedEventArgs<MaterialEntry> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null)
            {
                // unsubscribe
                if (Element != null)
                {
                    Element.HideKeyboard -= ElementOnHideKeyboard;
                }
                Control.EditText.KeyPress -= EditTextOnKeyPress;
                Control.EditText.TextChanged -= EditTextOnTextChanged;
            }

            if (e.NewElement != null)
            {
                var ctrl = CreateNativeControl();
                SetNativeControl(ctrl);
                _defaultEditTextForValues = new EditText(Context);

                SetText();
                SetHintText();
                SetTextColor();
                SetBackgroundColor();
                SetHintColor();
                SetIsPassword();
                SetKeyboard();

                // Subscribe
                Control.EditText.TextChanged += EditTextOnTextChanged;
                Control.EditText.KeyPress += EditTextOnKeyPress;
                if (Element != null)
                {
                    Element.HideKeyboard += ElementOnHideKeyboard;
                }
            }
        }

        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            if (e.PropertyName == Entry.PlaceholderProperty.PropertyName)
            {
                SetHintText();
            }

            if (e.PropertyName == Entry.TextColorProperty.PropertyName)
            {
                SetTextColor();
            }

            if (e.PropertyName == VisualElement.BackgroundColorProperty.PropertyName)
            {
                SetBackgroundColor();
            }

            if (e.PropertyName == Entry.IsPasswordProperty.PropertyName)
            {
                SetIsPassword();
            }

            if (e.PropertyName == Entry.TextProperty.PropertyName)
            {
                SetText();
            }

            if (e.PropertyName == Entry.PlaceholderColorProperty.PropertyName)
            {
                SetHintColor();
            }

            if (e.PropertyName == InputView.KeyboardProperty.PropertyName)
            {
                SetKeyboard();
            }
        }

        private void ElementOnHideKeyboard(object sender, EventArgs eventArgs)
        {
            var manager = (InputMethodManager)Application.Context.GetSystemService(Context.InputMethodService);
            manager.HideSoftInputFromWindow(Control.EditText.WindowToken, 0);
        }

        private void SetIsPassword()
        {
            Control.EditText.InputType = Element.IsPassword
                ? InputTypes.TextVariationPassword | InputTypes.ClassText
                : Control.EditText.InputType;
        }

        private void SetBackgroundColor()
        {
            Control.SetBackgroundColor(Element.BackgroundColor.ToAndroid());
        }

        private void SetHintText()
        {
            Control.Hint = Element.Placeholder;
        }

        private void SetHintColor()
        {
            if (Element.PlaceholderColor == Color.Default)
            {
                Control.EditText.SetHintTextColor(_defaultEditTextForValues.HintTextColors);
            }
            else
            {
                Control.EditText.SetHintTextColor(Element.PlaceholderColor.ToAndroid());
            }
        }

        private void SetTextColor()
        {
            if (Element.TextColor == Color.Default)
            {
                Control.EditText.SetTextColor(_defaultEditTextForValues.TextColors);
            }
            else
            {
                Control.EditText.SetTextColor(Element.TextColor.ToAndroid());
            }
        }

        private void SetKeyboard()
        {
            Control.EditText.InputType = Element.Keyboard.ToNative();
        }

        protected override TextInputLayout CreateNativeControl()
        {
            var layout = (TextInputLayout)LayoutInflater.From(Context).Inflate(Resource.Layout.TextInputLayout, null);
            var inner = layout.FindViewById(Resource.Id.textInputEdit);
            if (!string.IsNullOrWhiteSpace(Element.AutomationId))
            {
                inner.ContentDescription = Element.AutomationId;
            }
            return layout;
        }

        private void EditTextOnKeyPress(object sender, KeyEventArgs args)
        {
            args.Handled = args.KeyCode == Keycode.Enter;
            if (args.KeyCode == Keycode.Enter && args.Event.Action == KeyEventActions.Up)
            {
                Element.OnCompleted(this, EventArgs.Empty);
            }
        }

        private void EditTextOnTextChanged(object sender, TextChangedEventArgs args)
        {
            // As I type: send the EditText to the Forms Entry
            var selection = Control.EditText.SelectionStart;
            if (!_preventTextLoop)
            {
                Element.Text = args.Text.ToString();
            }
            if (Element == null || Element.Text == null) return;

            var index = selection > Element.Text.Length ? Element.Text.Length : selection;
            Control.EditText.SetSelection(index);
        }

        private void SetText()
        {
            _preventTextLoop = true;
            if (Control.EditText.Text != Element.Text)
            {
                // If I programmatically change text on the Forms Entry, 
                // send the forms entry to the native EditText
                Control.EditText.Text = Element.Text;
            }
            _preventTextLoop = false;
        }

        protected override void Dispose(bool disposing)
        {
            // this is here because the PopupPage disposes of the object in a weird way.
            // unsubscribe
            if (Element != null)
            {
                Element.HideKeyboard -= ElementOnHideKeyboard;
            }
            Control.EditText.KeyPress -= EditTextOnKeyPress;
            Control.EditText.TextChanged -= EditTextOnTextChanged;
            base.Dispose(disposing);
        }
    }
}

KeyboardExtensions.cs

using Android.Text;
using Xamarin.Forms;

namespace MyAppDroid.Extensions
{
    public static class KeyboardExtensions
    {
        public static InputTypes ToNative(this Keyboard input)
        {
            if (input == Keyboard.Url)
            {
                return InputTypes.ClassText | InputTypes.TextVariationUri;
            }
            if (input == Keyboard.Email)
            {
                return InputTypes.ClassText | InputTypes.TextVariationEmailAddress;
            }
            if (input == Keyboard.Numeric)
            {
                return InputTypes.ClassNumber;
            }
            if (input == Keyboard.Chat)
            {
                return InputTypes.ClassText | InputTypes.TextVariationShortMessage;
            }
            if (input == Keyboard.Telephone)
            {
                return InputTypes.ClassPhone;
            }
            if (input == Keyboard.Text)
            {
                return InputTypes.ClassText | InputTypes.TextFlagNoSuggestions;
            }
            return InputTypes.ClassText;
        }
    }
}

image

Disclaimer: I am not responsible for your issues ;) - if you have questions or enhancements, post them below.

This renderer currently only supports the following properties.

  • TextColor
  • Placeholder
  • IsPassword
  • BackgroundColor

feel free to add more :)

also, I didn't actually test binding... I did read somewhere that OnElementPropertyChanged doesn't fire on a ViewRenderer if you don't explicitly add the event hooks... that could have been a bug, I don't know. I just statically set these properties (for now).

«1

Posts

  • JacobPoulsen_JacobPoulsen_ DKMember ✭✭✭

    Hi @ChaseFlorell, great post, easy to implement! :)
    But there seems to be an error with the IsPassword property. If i use an Entry with IsPassword = true, the text in my Entry returns null when i want to process the user-input.
    Did you experience the same thing?

  • ChaseFlorellChaseFlorell CAInsider, University mod
    edited November 2015

    Well shit. I totally missed the boat on that one. I've updated the example above.
    Though I did say

    also, I didn't actually test binding...

    :blush:

    /cc @Jacob_b

  • JacobPoulsen_JacobPoulsen_ DKMember ✭✭✭

    Cool, thanks! I made myself a solution almost like yours, but its nice to have the working example posted. Happy coding!

  • MobleJosephMobleJoseph INMember

    I liked this one, really cool. But I am facing an issue for the Password. For the password, it keep resetting the keyboard. Even if i press the special character symbol, once i type a character, keyboard is reset. How i will be able to fix it ?

  • ChaseFlorellChaseFlorell CAInsider, University mod
    edited November 2015

    @MobleJoseph, I'm not sure, as you can see in the gif, the password is working. Can you zip up a small repro?

  • MobleJosephMobleJoseph INMember
    edited November 2015

    @ChaseFlorell

    For the entry, i just added the IsPassword="true" and Keyboard="Text"

    <Entry x:Name="password" Keyboard="Text" IsPassword="true" Placeholder="Password" />
    

    Password I was trying was [email protected]
    For typing @, i pressed the '?123' button to get the numeric + symbols keyboard. then it should stay there unless i toggle using the 'ABC' button. But after using this renderer, it was always getting reset to ABC once i type @, then again i need to press the '?123' to get the symbols + numbers back.

  • ChaseFlorellChaseFlorell CAInsider, University mod

    I apologize, but I don't have time to look at it at this time. Maybe drop some breakpoints and see what behavior your experiencing. Also, try (just for fun) removing the keyboard element from your xaml.

  • MobleJosephMobleJoseph INMember

    @ChaseFlorell What i could see is that once the native textchanged is fired, we try to set the forms textbox by the line
    Element.Text = textChangedEventArgs.Text.ToString();
    which raises OnElementPropertyChanged again where we call the SetText again. So in short we are setting the text in the native control again. How we should fix this one ?

  • OmarMohOmarMoh USMember ✭✭

    Cool , but what is the name of library for( OnElementChanged(ElementChangedEventArgse) function ??
    because it says the type could not be found , someone help me :smile:

  • xam--pivxam--piv USMember

    Have anybody tried to change FontSize? My problem is that it affects only inputting text size but not the hint size.

  • JacobPoulsen_JacobPoulsen_ DKMember ✭✭✭

    @MobleJoseph Did you ever find a solution to this issue? Im having a hard time figuring out why this resets the keyboard back to "ABC"

  • MatthewBelkMatthewBelk USMember ✭✭

    We've implemented this to good effect. I updated the renderer to display the correct keyboard based on the Keyboard property of the Entry. We're getting a very odd bug when we use a ContentView that contains an Entry that used by a ListView bound to the contents of an ObservableCollection. We simply cannot type in the field to edit the text. Also, when the collection loses an element, we get into a crazy GC loop that basically hangs the app. Without building a whole new test project, are there any suggestions as to where to look?

    Thanks.

  • MaterialEntryRenderer_Droid.cs

    using System.ComponentModel;
    using Android.App;
    using Android.Support.Design.Widget;
    using Android.Text;
    using Android.Views;
    using BiryaniBowl.Controls;
    using BiryaniBowl.Droid.Renderers;
    using Xamarin.Forms;
    using Xamarin.Forms.Platform.Android;
    using TextChangedEventArgs = Android.Text.TextChangedEventArgs;
    using View = Android.Views.View;

    [assembly: ExportRenderer(typeof(BiryaniBowl.Controls.MyEntry), typeof(MyEntryRenderer))]
    namespace BiryaniBowl.Droid.Renderers
    {
    public class MyEntryRenderer : Xamarin.Forms.Platform.Android.AppCompat.ViewRenderer<Entry, View>
    {
    private TextInputLayout _nativeView;

        private TextInputLayout NativeView
        {
            get { return _nativeView ?? (_nativeView = InitializeNativeView()); }
        }
    
    
    protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
        {
            base.OnElementChanged(e);
    
    
            if (e.OldElement == null)
            {
                var ctrl = CreateNativeControl();
                SetNativeControl(ctrl);
    
                NativeView.EditText.Text = Element.Text;
    
                NativeView.EditText.InputType = Element.IsPassword
    
                ? InputTypes.TextVariationPassword | InputTypes.ClassText
                : NativeView.EditText.InputType;
                NativeView.Hint = Element.Placeholder;
    
                NativeView.SetBackgroundColor(Element.BackgroundColor.ToAndroid());
    
                if (Element.TextColor == Color.Default)
                {
                    NativeView.EditText.SetTextColor(NativeView.EditText.TextColors);
                }
                else
                {
                    NativeView.EditText.SetTextColor(Element.TextColor.ToAndroid());
                }
    
            }
        }
    
    
         private void EditTextOnTextChanged(object sender, TextChangedEventArgs textChangedEventArgs)
         {
             Element.Text = textChangedEventArgs.Text.ToString();
             NativeView.EditText.SetSelection(Element.Text.Length);
         }
    
    
    
        private TextInputLayout InitializeNativeView()
        {
            var view = FindViewById<TextInputLayout>(Resource.Id.input_email);
            view.EditText.TextChanged += EditTextOnTextChanged;
            return view;
        }
    
        protected override View CreateNativeControl()
        {
            return LayoutInflater.From(Context).Inflate(Resource.Layout.Entry, null);
        }
    
    }
    

    }

    This is my solution for keyboard special character symbol. this is working for me

  • TomWalkerTomWalker CAInsider, University, Developer Group Leader ✭✭

    I've noticed a odd bug with the Android Keyboard suggestion. It seems like every second attempt at using a suggestion just deletes the text in the field and doesn't populated the suggestion. I've turned off keyboard suggestion for now but would like to know why this behavior is occurring.

  • ChaseFlorellChaseFlorell CAInsider, University mod

    I've made a lot of modifications since initially posting this. I've edited the original post with my updated renderer bits.

  • Hey,
    Firstly, thanks of course for sharing the code!

    It does not compile here, and maybe I can get some advice.

    The problem is this line:

    Element.HideKeyboard -= ElementOnHideKeyboard;

    The error I get is:

    Cannot assign to 'HideKeyboard' because it is a 'method group'

    Any Idea why I could get this error?

  • I was missing the KeyboardExtension! Now I am not getting that error anymore.

  • Ok, I was wrong, the error is not gone.
    I also cannot find "HideKeyboard" anywhere in the xamarin documentation. What is its exact type?

  • SanjayTejaniSanjayTejani USMember ✭✭✭

    I am getting e.PropertyName is "Render"...

  • ChaseFlorellChaseFlorell CAInsider, University mod
    edited January 2017

    Sorry all,

    @RudolfVonKrugstein the HideKeyboard is in the Custom Control

    public class MaterialEntry : Entry
    {
    
        public event EventHandler HideKeyboard;
        public void OnHideKeyboard(object sender, EventArgs args)
        {
            var handler = HideKeyboard;
            if (handler != null)
            {
                handler(sender, args);
            }
        }
    }
    

    @SanjayTejani I'm not entirely sure what issue you're running into.

  • ChaseFlorellChaseFlorell CAInsider, University mod

    Hey Guys, so I've iterated over this a bunch and finally got around to making a control.

    Check it out here.

    And you can get it on Nuget


  • DanH2DanH2 USMember ✭✭

    This is great, thank you for making it available! I ran into a issue with editing a existing model record. The Text value was getting wiped out in XfxEntryRendererDroid.OnElementChanged(). SetInputType() triggers OnTextChanged() which was causing the Text value to get lost. Calling SetText() before SetInputType() seems to fix it. Is that an okay change to make?

  • ChaseFlorellChaseFlorell CAInsider, University mod
    You bet, send in a pr
  • ChaseFlorellChaseFlorell CAInsider, University mod

    @DanH2, do you mind creating an issue for me to look into this?

  • piecypiecy MYMember ✭✭
    edited April 2017

    i try to install this Xfx.Controls in Xamarin.Form PCL but Failed with error message
    "Could not install package 'Xfx.Controls 1.0.3'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile259', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author."
    but in xamarin.android and xamarin.ios has no problem

    i trying to install Xfx.Controls: 1.0.3 in Xamarin.Form: 2.3.4.224

    @ChaseFlorell

  • MarkThrasherMarkThrasher USMember ✭✭

    I have attempted to use Xfx.Controls for the past day, but I have an issue. I posted this in StackOverflow. It appears to be a bug in Xamarin.Forms, or there is something fundamental that I am doing wrong. I made sure everything was AppCompat. The only page in which Xfx.Controls work is the mainpage. Any other page fails during xaml compile. I would appreciate any help. Here is the link...
    http://stackoverflow.com/questions/43382215/using-custom-class-renders-in-xamarin-forms

  • ChaseFlorellChaseFlorell CAInsider, University mod
    edited April 2017

    @MarkThrasher I've created an issue here,
    https://github.com/XamFormsExtended/Xfx.Controls/issues/11

    I've pushed the code, but am looking for some feedback on the nuget package structure (I'm new to .netstandard)
    https://github.com/XamFormsExtended/Xfx.Controls/tree/issue-#11

    edit

    I think I've got it fixed in the latest 1.0.4 release

  • MarkThrasherMarkThrasher USMember ✭✭
    edited April 2017

    @ChaseFlorell, your fix mentioned above did fix the issue with failing to compile. Thanks for that fix. However, I now get an exception when executing this line from the InitializeComponent() of the second page that is navigated to.
    this.LoadFromXaml(typeof(SecondPage));
    I did update Xfx.Controls to version 1.04 using Nuget.

    Edit: I changed the locationof the Xfx:Entry and it runs now. There is some sort of bug in Xamarin. If the Xfx is located in a TableSection, it doesn't work. I will post the actual file.

  • MarkThrasherMarkThrasher USMember ✭✭
    edited April 2017

    Here is the xaml file that fails to run due to unhandled exception when running InitializeComponent():

    "?xml version="1.0" encoding="utf-8" ?
    ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:xfx="clr-namespace:Xfx;assembly=Xfx.Controls"
    x:Class="RaceDay.ViewModels.Testing.Sensors"
    Title="sensors"
    ScrollView
    StackLayout Padding="10"
    TableView
    TableRoot
    TableSection Title="Basics"
    TextCell Text="Name" Detail="Mark"
    EntryCell Placeholder="weight" Keyboard="Numeric"
    xfx:XfxEntry Placeholder="Enter Name"

                    TableSection
                TableRoot
            TableView
        StackLayout
    ScrollView
    

    ContentPage"

    If I move the to between the Stacklayout and TableView, it runs correctly without any exceptions. I removed the < and > so it would post properly.

  • MarkThrasherMarkThrasher USMember ✭✭
    edited April 2017
    <?xml version="1.0" encoding="utf-8" ?>
    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 xmlns:xfx="clr-namespace:Xfx;assembly=Xfx.Controls"
                 x:Class="RaceDay.ViewModels.Testing.Sensors"
                 Title="sensors">
        <ScrollView>
            <StackLayout Padding="10">
                <TableView>
                    <TableRoot>
                        <TableSection Title="Basics"  >
                            <TextCell Text="Name" Detail="Mark"/>
                            <EntryCell Placeholder="weight" Keyboard="Numeric"/>
                            <xfx:XfxEntry Placeholder="Enter Name" />
    
                        </TableSection>
                    </TableRoot>
                </TableView>
            </StackLayout>
        </ScrollView>
    </ContentPage>
    
  • ChaseFlorellChaseFlorell CAInsider, University mod
    edited April 2017

    @MarkThrasher my first thought would be to do a full clean + rebuild.
    Also, if you've got time to troubleshoot with me, we can have a chat on the Xamarin Chat Slack under the channel #xfxcontrols

    Edit

    I just took a look at your code, you need to do the following

    <TableView>
        <TableRoot>
            <TableSection Title="Basics"  >
                <ViewCell>
                    <StackLayout Orientation="Horizontal">
                        <Label Text="Name" />
                        <xfx:XfxEntry Placeholder="Enter Name" />
                    </StackLayout>
                </ViewCell>
            </TableSection>
        </TableRoot>
    </TableView>
    
  • MarkThrasherMarkThrasher USMember ✭✭

    @ChaseFlorell, maybe we can chat to figure this out. I ran your exact code listed above, and the Xfx control appears, but there is no keyboard when it is pressed. Not sure why this is the case. If I change it to a standard Entry, the keyboard works as expected.

  • ChaseFlorellChaseFlorell CAInsider, University mod

    @MarkThrasher I'll be available on the slack channel on and off throughout the day.

  • blendedcoffeeblendedcoffee USMember

    @ChaseFlorell

    I'm struggling with setting the FloatingLabelActiveTextColor. It is always set to blue upon touch or hover.

  • ChaseFlorellChaseFlorell CAInsider, University mod

    Hey @blendedcoffee this is a known issue at this time. It's the next highest priority.

  • blendedcoffeeblendedcoffee USMember

    @ChaseFlorell

    I'm trying to import and extend the project but it gives me an error of unsupported .NETPortable,version=5.0

    My environment is Mac and I'm using Xamarin Studio

  • ChaseFlorellChaseFlorell CAInsider, University mod
  • matheusluteromatheuslutero BRMember

    @xam--piv said:
    Have anybody tried to change FontSize? My problem is that it affects only inputting text size but not the hint size.

    I solved this problem as follows:

    In XfxEntryRendererDroid.cs change the methos:

    `
    private void ControlOnFocusChange(object sender, FocusChangeEventArgs args)
    {
    if (args.HasFocus)
    {
    //My Change
    EditText.Hint = "";
    Control.Hint = Element.Placeholder;

                var manager = (InputMethodManager) Application.Context.GetSystemService(Context.InputMethodService);
    
                EditText.PostDelayed(() =>
                    {
                        EditText.RequestFocus();
                        manager.ShowSoftInput(EditText, 0);
                    },
                    100);
            }
            else //My Change
            {
                if (string.IsNullOrWhiteSpace(EditText.Text))
                {
                    Control.Hint = "";
                    EditText.Hint = Element.Placeholder;
                }
                else
                {
                    Control.Hint = Element.Placeholder;
                    EditText.Hint = "";
                }
    
            }
    
            var isFocusedPropertyKey = Element.GetInternalField<BindablePropertyKey>("IsFocusedPropertyKey");
            ((IElementController)Element).SetValueFromRenderer(isFocusedPropertyKey, args.HasFocus);
        }
    
    
    private void SetHintText()
        {
            //My Change
            //Control.Hint = Element.Placeholder;
            EditText.Hint = Element.Placeholder;
        }
    

    `

  • matheusluteromatheuslutero BRMember
    edited July 2017

    I solved this problem as follows:

    In XfxEntryRendererDroid.cs change the methos:

    private void ControlOnFocusChange(object sender, FocusChangeEventArgs args)
    {
    if (args.HasFocus)
    {
    //My Change
    EditText.Hint = "";
    Control.Hint = Element.Placeholder;
    
                var manager = (InputMethodManager) Application.Context.GetSystemService(Context.InputMethodService);
    
                EditText.PostDelayed(() =>
                    {
                        EditText.RequestFocus();
                        manager.ShowSoftInput(EditText, 0);
                    },
                    100);
            }
            else //My Change
            {
                if (string.IsNullOrWhiteSpace(EditText.Text))
                {
                    Control.Hint = "";
                    EditText.Hint = Element.Placeholder;
                }
                else
                {
                    Control.Hint = Element.Placeholder;
                    EditText.Hint = "";
                }
    
            }
    
            var isFocusedPropertyKey = Element.GetInternalField<BindablePropertyKey>("IsFocusedPropertyKey");
            ((IElementController)Element).SetValueFromRenderer(isFocusedPropertyKey, args.HasFocus);
        }
    
        private void SetHintText()
            {
                //My Change
                //Control.Hint = Element.Placeholder;
                EditText.Hint = Element.Placeholder;
            }
    
Sign In or Register to comment.