码迷,mamicode.com
首页 > Windows程序 > 详细

Wpf UserControl使用 KeyBinding,失效问题

时间:2020-02-19 05:36:30      阅读:89      评论:0      收藏:0      [点我收藏+]

标签:end   ted   detail   获取   route   void   public   vat   property   

原文: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);
        }

Wpf UserControl使用 KeyBinding,失效问题

标签:end   ted   detail   获取   route   void   public   vat   property   

原文地址:https://www.cnblogs.com/lonelyxmas/p/12329548.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!