永利棋牌官方下载-www.55402.com-永利国际唯一指定官网

永利棋牌官方下载提供最新最好玩的真人游戏,www.55402.com是澳门国际娱乐平台官方网站唯一授权会员登录手机版,www.316net,www.366net,516.net,626.net,766.net,www.565.net,www.16.net,bwin62.com,bwin180.com,永利国际唯一指定官网为新老顾客提供更多的精彩娱乐项目,,所有的玩家都可以得到注册送体验金的巨大福利是设身处地为玩家量身订造的经典网站。

WPF中Popup上的textbox无法切换到中文输入法

As Marco Zhou has said in the msdn forum ():
Windows will only send WM_WPF中Popup上的textbox无法切换到中文输入法。IME_SETCONTEXT message to the active window, Popup by default is designed to be shown with WM_EX_WPF中Popup上的textbox无法切换到中文输入法。NOACTIVE which means that it doesn't in active state when displaying, that's why IME could not work correctly in this regard, to workaround this issue, you could try set the Popup as the active window using win32 SetActiveWindow() API.

So the workaround is use MyPopup instead of Popup:

public class MyPopup : Popup
WPF中Popup上的textbox无法切换到中文输入法。{
    [DllImport("user32.dll")]
WPF中Popup上的textbox无法切换到中文输入法。WPF中Popup上的textbox无法切换到中文输入法。    static extern IntPtr SetActiveWindow(IntPtr hWnd);

    static MyPopup()
    {
        EventManager.RegisterClassHandler(
            typeof(MyPopup),
            Popup.PreviewGotKeyboardFocusEvent,
            new KeyboardFocusChangedEventHandler(OnPreviewGotKeyboardFocus),
            true);
    }

    private static void OnPreviewGotKeyboardFocus(Object sender, KeyboardFocusChangedEventArgs e)
    {
        var textBox = e.NewFocus as TextBoxBase;
        if (textBox != null)
        {
            var hwndSource = PresentationSource.FromVisual(textBox) as HwndSource;
            if (hwndSource != null)
            {
                SetActiveWindow(hwndSource.Handle);
            }
        }
    }
}

官方解决方案

使用的话自己建一个类代码如上,控件内local:MyPopup 等同于Popup,亲测好使,实用。

参考:

本文由永利棋牌官方下载发布于永利棋牌官方下载,转载请注明出处:WPF中Popup上的textbox无法切换到中文输入法

您可能还会对下面的文章感兴趣: