在WP7 TextBox.Focus()时WebBrowser控件是present页面上不起作用 [英] In WP7 TextBox.Focus() does not work when WebBrowser control is present on page

查看:106
本文介绍了在WP7 TextBox.Focus()时WebBrowser控件是present页面上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将焦点设置文本框。问题是,当一个WebBrowser控件是页面上的present,仿佛被选中文本框会显示SIP,但光标不可见的文本框和输入不会转到文本框。

I need to set focus on the textbox. The problem is when a WebBrowser control is present on the page, the SIP is displayed as if textbox is selected, but cursor is not visible in textbox and the input does not go to the textbox.

如果我评论WebBrowser控件时,则如预期的行为 - 光标闪烁在页面加载时,文本框

If I comment the WebBrowser control out, then the behavior is as expected - cursor is blinking in the TextBox when page is loaded.

下面是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>

而codebehind:

And the codebehind:

void MainPageLoaded(object sender, RoutedEventArgs e)
{
    txt.Focus();
}

我曾尝试不同的解决方法,但没有运气。
即我试图从加载调用的SetFocus,NavigatedTo等事件。我也试图将焦点设置到其他控件,然后回文本框,没有运气无论是。

I have tried the different workarounds, but no luck. Namely I have tried to call SetFocus from the Load, NavigatedTo etc events. I have also tried to set focus to some other control and then back to the textbox, no luck either.

可能有人为这个问题提供了一个解决办法?

Could someone provide a workaround for this problem?

BTW,问题重现在模拟器上,在HTC莫扎特和奖杯设备的所有安装NoDo更新。

BTW, the problem is reproduced on the emulator, on HTC Mozart and Trophy devices all with NoDo update installed.

推荐答案

我们已经提供了对WP7的pre-芒果版本的情况下,一个黑客,我没有检查的情况事前。
好消息,伙计们!

As we have provided a hack for the case for pre-Mango versions of WP7, I had not checked the scenario beforehand. The good news, guys!

在WP7芒果问题不存在!

In WP7 Mango the problem does not exist!

这篇关于在WP7 TextBox.Focus()时WebBrowser控件是present页面上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆