I have a page with two text boxes, a check box and another two text boxes below at the bottom.
When I click on the check box, i want to set focus to the text box below it. This works fine, the soft-keyboard appears and the screen scrolls up to reveal the text box above the keyboard.
However, if either TextBox1 or TextBox2 is currently in focus and the keyboard is already showing, setting focus from the CheckBox_Click event will reset the screen and it scrolls back down.
I'm guessing that the events clash with one another - TextBox loses focus and hides the keyboard + scroll the screen back down - TextBox got focus from outside and shows the keyboard (but doesn't scroll the screen up)
Can this be prevented somehow?
Here's a simplified version of the xaml and code
The xaml:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<StackPanel Margin="0,100,0,0">
<TextBox x:Name="TextBox1" />
<TextBox x:Name="TextBox2" />
<CheckBox Content="Click Me" Click="CheckBox_Click" />
<TextBox x:Name="TextBox3" />
<TextBox x:Name="TextBox4" />
</StackPanel>
</Grid>
the code behind:
private void CheckBox_Click(object sender, RoutedEventArgs e)
{
TextBox3.Focus();
}