如何触发“某事”当在组合框中再次选择相同的项目时 [英] how to trigger "something" when the same item is being selected again in combobox

查看:87
本文介绍了如何触发“某事”当在组合框中再次选择相同的项目时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SelectionChanged事件的问题:如果用户选择的项目与当前正在选择的项目相同,则选择不会更改,因此不会触发此事件。



只要鼠标点击该项目和该项目,我可以使用什么其他事件处理程序(或其他方式)来发布事件而不管所选项目是否被更改正在被选中。



场景:在组合框中选择一个项目会触发一些功能。然后再打开组合框并选择与之前相同的项目,它必须再次触发该功能。



我目前正在MVVM中使用SelectionChanged事件附加行为,我的组合框位于gridview列内。

Issue with SelectionChanged event: If the user choose the same item as the item is currently being selected then the selection is not changed and therefore this event will not be triggered.

What other event handler(or other ways) I may use to issue an event regardless of the selected item is changed or not as long as the mouse clicked on that item and that item is being selected.

Scenario: Select an item in combobox it will trigger some function.And then again, open combobox and select same item as previously selected and it has to trigger the function again.

I am currently using SelectionChanged event attached Behaviour in MVVM and my combobox is inside the gridview column.

推荐答案

我建​​议你用两个按钮替换 ComboBox ,这是一种更好更清洁的方法。这里不需要 ComboBox ,因为它不包含很多项。
I would suggest you to replace the ComboBox with two Buttons, which is a better and cleaner approach. There is no need to have a ComboBox here, as it does not include many items.


在其中 [ ^ ]



你最好的选择是使用我认为的点击事件(尽管如果用户使用键盘你可能想稍微研究一下)你也可以从这个处理程序中获取所选项目假设。



希望这会有所帮助。
Look here[^]

your best bet is to use the click event I think (although if the user uses the keyboard you might want to research that a bit) You can get the selected item from this handler as well I assume.

hope this helps.


这篇关于如何触发“某事”当在组合框中再次选择相同的项目时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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