How to trigger "Focused"of a Object in Android(Xamarin.forms)

ClawRageClawRage Member ✭✭
edited May 6 in Xamarin.Forms

How to trigger "Focused"of a Object in Android

I am troubled by this problem for a few days, I want to run some codes when object Frame /Button /Label been clicked and after user click onther object.So I want to use the Focused /Unfocused.

Although it works very well on UWP(windows),but on Android emulator always don't work.can't trigger Focused or Unfocused.

Is I miss some settings on Android or just because only Entry /Editor has Focused function in Android?really!?

Just like this:

Button TestButton = new Button
{
Test="hello"
};

TestButton.Focused+= (sender, args) => 
    {
Test+="FF";
};

TestButton.Clicked+= (sender, args) => 
    {
Test+="CC";
};

when click once, will be "helloFFCC" in UWP,but "helloCC" in Android.

Best Answer

Answers

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    Button doesn't have a property called Test
    So this shouldn't even compile. So clearly you're not showing us your actual code and thus wasting our time.

  • ClawRageClawRage Member ✭✭
    edited May 7

    WOW ,Really like this!!!?!

    Even Frame /Grid not support Focused by this way

    Button TestButton = new Button
    {
    Text="hello"
    };
    Frame TestFrame = new Frame{};
    Test.Content=TestButton ;
    
    TestFrame.Focused+= (sender, args) => 
        {
    TestButton.Text+="FF";
    };
    
    TestButton.Clicked+= (sender, args) => 
        {
    Text+="CC";
    };
    

    It's also would be "helloCCFF" in UWP,"helloCC" in Android.

Sign In or Register to comment.