Hey Marlon,
The ComboBox class does some magic to keep several properties in sync and to make sure the popup is closed when a selection is made.
Rather than using a ComboBox, you might consider exposing an IsDropDownOpen property on your control and then just using a Popup in your style. The IsOpen property of the Popup can then be bound to the IsDropDownOpen property of your DatePicker.
This is similar to the approach used by ComboBox itself, but it gives you full control over when the popup is opened or closed. And if someone chooses to retemplate the control without a Popup, everything still works great.
I've pasted part of a (really old) template for one of my controls of yor. Apologies for the outdated snippet... the approach should still be valid. (This was from the days when every control in the framework was composed with dozens of elements... yikes! what a waste!... prior to the bright idea of introducing the ButtonChrome theme class. And evidently I was really into blue at the time. :-s)
Cheers,
-dw
<Border
> />>
Dr. WPF - Online Office at http://www.drwpf.com/blog/
Not sure what happened with the formatting of the snippet in that last mail... here it is in black and white:
Quoting "Dr. WPF"
<a...@drwpf.com>:
>
>
> Hey Marlon,
>
> The ComboBox class does some magic to keep several
properties in
> sync and to make sure the popup is closed when a
selection is made.
>
> Rather than using a ComboBox, you
might consider exposing an
> IsDropDownOpen property on your control
and then just using a Popup in
> your style. The IsOpen property of
the Popup can then be bound to the
> IsDropDownOpen property of your
DatePicker.
>
> This is similar to the approach used by
ComboBox itself, but it
> gives you full control over when the popup is
opened or closed. And
> if someone chooses to retemplate the control
without a Popup,
> everything still works great.
>
> I've pasted part of a /(really old)/ template for one of my
Oh crap! And update the RelativeSource references to use {RelativeSource TemplatedParent} rather than "\TemplatedParent"... that code is older than I thought (~ 4 yrs).