在杀死TabletKeyboard(TabTip.exe)应用程序的过程后,在wpf中没有恢复到原来的大小

我有一个运行在Windows 8平板电脑上的wpf应用程序。 并且当焦点在任何TextBox上时,为了键入键盘。

我正在调用TabTip.exe进程来显示键盘,当键盘显示时我的应用程序缩小了。 在所有操作之后,有一个保存按钮。 当我单击保存按钮时,键盘应该消失,我的应用程序应该恢复到原始大小。

我正在杀死进程TabTip.exe以关闭键盘,但应用程序将不会重新调整其原始大小。

我试过了:

 if (process.ProcessName == "TabTip") { Application.Current.MainWindow.VerticalAlignment = VerticalAlignment.Stretch; process.Kill(); Application.Current.MainWindow.Height = SystemParameters.WorkArea.Height; Application.Current.MainWindow.Width = SystemParameters.WorkArea.Width; Application.Current.MainWindow.WindowState = WindowState.Normal; Application.Current.MainWindow.WindowState = WindowState.Maximized; break; } 

有人知道在杀死TabTip.exe后将应用程序恢复到原始大小吗?

Windows 8键盘存在许多渲染问题。 这些可以通过以较小的模式启动键盘来减轻(相当于按下最小化按钮)。 然后,它在WPF中发挥得更好,实际上在启动和关闭进程时最小化和扩展。

这需要在此模式下启动该过程,并以比您现在更好的方式关闭它

包括这些库:

 using System.Diagnostics; using System.Runtime.InteropServices; using System.Windows.Interop; 

并定义这个外部函数:

 [return: MarshalAs(UnmanagedType.Bool)] [DllImport("user32.dll", SetLastError = true)] public static extern bool PostMessage(int hWnd, uint Msg, int wParam, int lParam); [DllImport("user32.dll")] public static extern IntPtr FindWindow(String sClassName, String sAppName); 

打开键盘:

 public static void openKeyboard() { ProcessStartInfo startInfo = new ProcessStartInfo(@"C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe"); startInfo.WindowStyle = ProcessWindowStyle.Hidden; myProcess = Process.Start(startInfo); } 

并关闭它:

 public static void closeKeyboard() { uint WM_SYSCOMMAND = 274; uint SC_CLOSE = 61536; IntPtr KeyboardWnd = FindWindow("IPTip_Main_Window", null); PostMessage(KeyboardWnd.ToInt32(), WM_SYSCOMMAND, (int)SC_CLOSE, 0); } 

这将为您提供屏幕键盘上最佳表现的Windows 8。 运气好的话,它会解决你的渲染问题。

阿宾 – 你问过关闭键盘窗口而不是杀死进程。 这就是我在WPF应用程序中所做的事情,通过关闭窗口,我的主应用程序窗口将按预期resize。 这里有一个用于演示隐藏键盘的快速控制台应用程序(请注意,这假设您在停靠模式下使用键盘而不是浮动最小模式):

 using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; namespace TabTipTest { class Program { [DllImport("user32.dll")] public static extern IntPtr FindWindow(String sClassName, String sAppName); [DllImport("user32.dll")] public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam); ///  /// The command for a user choosing a command from the Window menu (see http://msdn.microsoft.com/en-gb/library/windows/desktop/ms646360(v=vs.85).aspx). ///  public const int WM_SYSCOMMAND = 0x0112; ///  /// Closes the window. ///  public const int SC_CLOSE = 0xF060; static void Main(string[] args) { HideKeyboard(); } ///  /// Gets the window handler for the virtual keyboard. ///  /// The handle. public static IntPtr GetKeyboardWindowHandle() { return FindWindow("IPTip_Main_Window", null); } ///  /// Hides the keyboard by sending the window the close command. ///  public static void HideKeyboard() { IntPtr keyboardHandle = GetKeyboardWindowHandle(); if (keyboardHandle != IntPtr.Zero) { SendMessage(keyboardHandle, WM_SYSCOMMAND, SC_CLOSE, 0); } } } }