How can i create two sections to focus and other to writting?

Viewed 107

This code i am using to focus of a entry, its a custon entry

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

    if (e.PropertyName == Entry.IsFocusedProperty.PropertyName )
    {
        //place1. this code is use to focus
    }

    // place2. here enter the text when the user written
}

How can i know if the user is writting? but dont enter to both places.

1 Answers

Option 1:You could set the TextProperty to check the user editing .

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

    if (e.PropertyName == Entry.IsFocusedProperty.PropertyName)
    {
        //place1. this code is use to focus
    }

    if (e.PropertyName == Entry.TextProperty.PropertyName)
    {
        //place2. this code is use to edit 

        var content = Element.Text;
    }
}

Option 2:

You could set the TextChanged of the Entry .

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

    if(Control!=null)
    {
        Element.TextChanged += Element_TextChanged;
    }

}

private void Element_TextChanged(object sender, TextChangedEventArgs e)
{
    // var content = Element.Text;
}
Related