Wpf UserControl使用 KeyBinding,失效问题

原文:
Wpf UserControl使用 KeyBinding,失效问题

我的问题根源是UserControl未获取相应焦点,在UserControl后台添加如下

 public AccountDetailView()
        {
            InitializeComponent();
            this.IsEnabledChanged +=new DependencyPropertyChangedEventHandler(AccountDetailView_IsEnabledChanged);  
        }

        private void control_detail_Loaded(object sender, RoutedEventArgs e)
        {
            tb_detail.Focusable = true;
            Keyboard.Focus(this);
        }

        void AccountDetailView_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (!Convert.ToBoolean(e.NewValue)) return;
            this.Focusable = true;
            Keyboard.Focus(this);
        }