How to set focus to a control? RRS feed

  • Question

  • Xaml:

                <TextBox x:Name="textBox"></TextBox>
                <Button x:Name="button1" Click="button1_Click_1">Set focus</Button>


            private void button1_Click_1(object sender, RoutedEventArgs e)

    For unknown reasons, I totally am unable to use this method.

    The method always returns false no matter what controls I picked, which means the control is unfocus-able

    Does anyone know what causes this behaviour?

    Saturday, June 21, 2014 2:39 AM

All replies

  • That code as is will work. If it's not working for you you're doing something different.

    What control are you trying to focus and from where are you focusing it?

    Can you show some minimal code that demonstrates the problem?


    Saturday, June 21, 2014 3:15 AM