Silverlight ComboBox selection changed or reselected event
On a Silverlight ComboBox, the SelectionChanged event does not fire when you open the dropdown list, then click on the currently selected item. What's the best way to have an event/method trigger when this happens? (in addition to anything that would normally trigger SelectionChanged, i.e. they either click an unselected or selected item; but not when they just click off of the dropdown)
I currently have DataTe开发者_如何转开发mplates set up for the items in the list. I tried to attach to the MouseLeftButtonUp events of the elements in that, but there's a margin around the items, so it doesn't always register a click that closes the combobox and selects the item.Have you considered the "DropDownClosed" event?
I know it's been a long time since the last comment, but I'll post my solution in case someone out there is experiencing the same problem. The only way I managed to "re-select" the currently selected item was to modify the ComboBoxItemTemplate like this:
<Style TargetType="ComboBoxItem">
....
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBoxItem">
<Grid ... MouseLeftButtonDown="Grid_MouseLeftButtonDown">
...
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Now, in the Grid_MouseLeftButtonDown event I deselect the current item; the mouse click will then be handled as usual, selecting the element which is under the mouse cursor.
精彩评论