1
我目前正在WPF中做一个触摸应用程序。它迄今为止效果很好,但有时我需要启动内置的Web浏览器控件。我的问题是,尽管缩放,滚动和这样的工作,我不能让Windows 8的虚拟键盘(如IE 11)显示,当用户的焦点在Web文本输入。WebBrowser控件中的虚拟Win8键盘
有什么办法可以实现这样的行为吗?请记住,我的WPF应用程序应该始终运行最高和全屏,因此我不能要求用户手动启动虚拟键盘。
我目前正在WPF中做一个触摸应用程序。它迄今为止效果很好,但有时我需要启动内置的Web浏览器控件。我的问题是,尽管缩放,滚动和这样的工作,我不能让Windows 8的虚拟键盘(如IE 11)显示,当用户的焦点在Web文本输入。WebBrowser控件中的虚拟Win8键盘
有什么办法可以实现这样的行为吗?请记住,我的WPF应用程序应该始终运行最高和全屏,因此我不能要求用户手动启动虚拟键盘。
最后发现它here ...正如所写,Winforms WebBrowser对HTMLDocument有更好的包装,使得它比使用MSHTML interop更容易。这里有一个代码片段:
C#:
public partial class BrowserWindow : Window
{
public BrowserWindow(string url)
{
InitializeComponent();
WebView.ScriptErrorsSuppressed = true;
WebView.AllowNavigation = true;
WebView.Navigate(new Uri(url));
WebView.DocumentCompleted += LoadCompleteEventHandler;
}
private void LoadCompleteEventHandler(object sender, WebBrowserDocumentCompletedEventArgs navigationEventArgs)
{
HtmlElementCollection elements = this.WebView.Document.GetElementsByTagName("input");
foreach (HtmlElement input in elements)
{
if (input.GetAttribute("type").ToLower() == "text")
{
input.GotFocus += (o, args) => VirtualKeyBoardHelper.AttachTabTip();
input.LostFocus += (o, args) => VirtualKeyBoardHelper.RemoveTabTip();
}
}
}
}
XAML:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
x:Class="PlayPlatform.BrowserWindow"
Title="Browser" ResizeMode="NoResize"
WindowStartupLocation="CenterScreen" WindowState="Maximized" Topmost="True" ShowInTaskbar="False" WindowStyle="None" AllowDrop="False" AllowsTransparency="False">
<WindowsFormsHost HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<wf:WebBrowser x:Name="WebView" />
</WindowsFormsHost>
</Window>
的VirtualKeyBoardHelper方法manuallly启动和终止tabtip.exe。
你从哪里找到VirtualKeyBoardHelper? –
嘿!这是你自己的班级使用。谢谢! –