I need to set focus on the text box. The problem is that the WebBrowser control is present on the page, SIP is displayed as if a text field had been selected, but the cursor does not appear in the text field, and the input does not fall into the text field.
If I comment on the WebBrowser control, then the behavior will be as expected - the cursor blinks in the TextBox when the page loads.
Here is the XAML:
<phone:PhoneApplicationPage
x:Class="WP7Sample.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
Loaded="MainPageLoaded">
<StackPanel x:Name="LayoutRoot">
<TextBox x:Name="txt"/>
<phone:WebBrowser/>
</StackPanel>
</phone:PhoneApplicationPage>
And codebehind:
void MainPageLoaded(object sender, RoutedEventArgs e)
{
txt.Focus();
}
I tried different workarounds but no luck. Namely, I tried to call SetFocus from the events Load, NavigatedTo, etc. I also tried to set the focus to some other control, and then back to the text box, also no luck.
- ?
BTW, , HTC Mozart Trophy NoDo.