禁止通过arrrow键导航的WPF下拉组合的onSelectedIndex更改事件 [英] Disabling the onSelectedIndex changed event of WPF dropdown combo on navigating through arrrow keys

查看:115
本文介绍了禁止通过arrrow键导航的WPF下拉组合的onSelectedIndex更改事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我有我的WPF下拉组合框,然后使用导航键左,右箭头键会选择改变的情况下对每个项目的射击。选择的值项

When I am having a value item selected in my WPf DropDown Combo Box then navigating using keys Left and right arrow keys result in firing of selected changed event for each item.

如何克服这个问题

推荐答案

最方便,适合的方式,我发现要克服这个问题如下:

The most easy and suitable way I found to overcome this problem is as follows:

而不是使用SelectedIndexChanged事件我用DropDownClosed事件和被wriiten较早内选择指数改变了,如果条件是检查是否一个项目被选中或不符合转移到本次活动的所有code。就像这一点。

rather than using SelectedIndexChanged event I used on DropDownClosed event and all code that is wriiten earlier inside selected index changed moved to this event under a if condition that checks whether a item is selected or not. Like this.

 private void OnCmbOperatorsListDropDownClosed(object sender, EventArgs e)
        {
            if (cmbOperatorsList.SelectedIndex != -1)
                InsertText(cmbOperatorsList.SelectedValue.ToString()); 
               //Do whatever u want with selected item
        }

因此​​,在这样的时候我通过箭头键导航SelectedIndexChagned事件不会解雇或因为我没有使用该事件,因此它不会产生任何问题。

So in this way when i navigate through Arrow keys SelectedIndexChagned event will not fired or since i haven't used that event so it will not create any problem.

这篇关于禁止通过arrrow键导航的WPF下拉组合的onSelectedIndex更改事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆