Suggestion for DatePicker DropDown Button

May 4, 2009 at 9:06 AM

I'm using the DatePicker from the WPF ToolKit with a custom style. In my style, I would like to use a ToggleButton instead of the normal button, but this doesn't work without changing two lines of code in DatePicker.cs.

The field for the DropDownButton is defined as

private ButtonBase _dropDownButton;

No problem so far. But in the TemplatePart attribute, the button is not defined as ButtonBase, but as Button instead:

[TemplatePart(Name = DatePicker.ElementButton, Type = typeof(Button))]

Also, in the OnApplyTemplate method, the button is also defined as Button:

_dropDownButton = GetTemplateChild(ElementButton) as Button;

By changing those two lines to ButtonBase, it's also working with a ToggleButton.

Maybe you can change that in future releases?