首页 > Windows开发 > 详细

Wpf UserControl使用 KeyBinding,失效问题

时间:2020-02-19 01:20:57      阅读:92      评论:0      收藏:0      [点我收藏+]
原文: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,失效问题

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!