Click here to Skip to main content
15,893,668 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Comments
Ideally it should not. If you don't change anything, why it would be fired? If it is already fired, then the work you wanted to do is already done. So, no need to do that again an again for the same option, right?
chankayudu 13-Jun-14 8:45am    
Thank for quick response.

Actually my scenario is ,
1) I have combobox which contains two items "value" and "By Rule".
2) Whenever user selects "By Rule" it will open new window, and i will perform some operations in that window.
3) The data related to those operations will get saved in xml then the window gets closed.
4) If i changed the selected item to "value" in combobox the data in xml will be deleted.
5)So, without deleting the data in the xml i need to open the window again by selecting the combobox item "By Rule" which will show the saved data.

I tried to add button so that if the combobox item is "By Rule" i will click button it will open the window with previous data but user is not agreed to it.

Now i need the way to trigger the window whenever i selected "By Rule".
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.
chankayudu 13-Jun-14 15:30pm    
Thank you for your solution.

sorry i gave wrong example. I have many value items and one "By Rule" which is will opens the window and this combo box is inside a grid view cell.
Look, this can't be possible with change event of ComboBox. Either add number of buttons for number of items, else open one popup from the cell and show all items as buttons. You have to think of a way which would fire the function every time and change event cannot do that for you.

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.
 
Share this answer
 
Comments
phil.o 13-Jun-14 13:34pm    
I agree with you; a custom two-mutually-exclusive-buttons control would be much more manageable, as well as having the advantage of being unambiguous to the end-user.
Exactly. Thanks phil.o. :)
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900