Forum Xamarin.Forms

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

How can i focus the particular stacklayout when clicking the button ?

I'm new to xamarin can anyone help ,when tapping the image button it will focus the particular stacklayout in xamarin forms

Answers

  • JohnHardmanJohnHardman GBUniversity admin

    @adhitya1507 said:
    I'm new to xamarin can anyone help ,when tapping the image button it will focus the particular stacklayout in xamarin forms

    StackLayout is not focusable.

    What are you trying to achieve (post a screenshot if it helps)

  • YelinzhYelinzh Member, Xamarin Team Xamurai
    edited August 2020

    when tapping the image button it will focus the particular stacklayout in xamarin forms

    @adhitya1507 Detect the click event of the button and call the Focus() method to make a control focused.

    Check the code:

    <StackLayout x:Name="layout">
        <ImageButton Source="xxx" Clicked="Button_Clicked"/>
        <Entry x:Name="entry" Focused="entry_Focused"/>
    </StackLayout>
    

    Button clicked event.

    private void Button_Clicked(object sender, EventArgs e)
    {
        entry.Focus();
    }
    

    But the StackLayout doesn't support the focus function. What feature you want to achieve 'when focusing the layout'?

Sign In or Register to comment.