I’ve started to use my WpfSplitButton control in one of my projects and I’m discovering some difficulties and/or inconveniences with it. I’m now resolving some of those issues and will release an update in a few days.
First off there is two events that need to be handle: Click and ItemSelected. ItemSelected is a straightforward event to handle and makes sense. However the Click event, is not so straightforward. This is because you don’t have any clue what the current Item for the SplitButton is. In order to figure it out you have to look at the SplitButton’s Content property and try to match it with one of the Header properties of the Items. This is exactly what the updated version of SplitButton will now do for you behind the scenes. Now the only event that really needs to be handled is the ItemSelected event, and the Click event in most cases will now be irrelevant. Another option would be to keep track of the current item with a property of some sort, but I didn’t end up going that route and don’t see any reason to change it now.
Secondly, the behavior of the drop-down does not seem to be “standard”. In most implementations the drop-down stays open, instead of snapping back on MouseUp. To fix this the updated version of SplitButton will now have a DependencyProperty called IsSnapBackEnabled. When set to True, you’ll have the previous behavior of the snap-back. When set to False, you’ll get the more standard behavior of the drop-down staying open and waiting for an additional MouseUp. The default for the updated version of the SplitButton will now be False for IsSnapBackEnabled, giving the standard behavior users would expect to see.
Lastly, ItemTemplate needs to be implemented. This will be a must when styling comes into play. To support this the new SplitButton will be using an ItemsControl for its Items container, instead of a ItemsPresenter. This also allows support for AlternationCount and many other properties associated with the visualization of the Items.
You can expect this update to be released on CodePlex sometime next week. If you have any other suggestions, please free to leave a comment.
Yours is the best WPF Splitbutton implementation in my opinion and these improvements should make it the de-facto splitbutton for WPF. I look forward to the 1.0.0.2 release. And thanks for your efforts…
Comment by Tony — August 15, 2009 @ 9:20 pm