WPFユーザーコントロールは失敗、キーバインドを使用します

オリジナル: 、WPFユーザーコントロールの使用キーバインドの失敗

問題の根本は、ユーザーコントロールは、次のようにバックグラウンドで追加、私は適切なフォーカスユーザーコントロールを取得していないです

 パブリックAccountDetailView()
        {
            のInitializeComponent();
            this.IsEnabledChanged + =新しいDependencyPropertyChangedEventHandler(AccountDetailView_IsEnabledChanged)。  
        }



        プライベートボイドcontrol_detail_Loaded(オブジェクト送信者、RoutedEventArgs e)の
        {
            tb_detail.Focusableがtrue =。
            Keyboard.Focus(この);
        }




        ボイドAccountDetailView_IsEnabledChanged(オブジェクト送信者、DependencyPropertyChangedEventArgs E)
        {
            IF(!Convert.ToBoolean(e.NewValue))のリターン;
            this.Focusable =はtrue。
            Keyboard.Focus(この);
        }

おすすめ

転載: www.cnblogs.com/lonelyxmas/p/12329548.html