Split Button Click behaviour

Ribbon for WPF Forum

Posted 16 years ago by Ravi Kumar
Version: 3.0.0402
Thanks for the new WPF Studio Release. The ribbon is now responding very faster.

I have a split button in my ribbon which has a click event associated with the split button itself (i.e. the big button) and it also have some menu items where each menu item has a click event associated with. With the latest WPF studio (v3.0.0402), when I select a menu item, in addition to the click event of menu item, the click event of the split button is also firing. This worked correctly with the earlier version i.e. v1.0.0348. Is the behaviour of this changed? What should be done to have separate click events for both the menu items and the split button?

Thanks in advance for your suggestion.
Ravi Kumar

Comments (2)

Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Ravi,

I think this is because the Click event is now an attached event and it bubbles up, similar to how WPF's mouse events work. If you look at the RoutedEventArgs when it fires, you'll see that e.Source is the menu item you clicked.

I did a stack trace breakpoint in this scenario and can confirm that the SplitButton itself isn't firing Click, it's the child control that is doing it and bubbling the event up the logical chain of controls.

So what you'll want to do is check the e.Source to make sure you are looking at the right control. Maybe another way to do it is say only process the event if "sender == e.Source". That way you know that the sender of the event (always the SplitButton) is the source of the event.

I hope that helps. Let us know if you have any more questions.

Actipro Software Support

Posted 16 years ago by Ravi Kumar
Thanks a lot, that worked out.

The latest build of this product (v24.1.2) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.