I need a button that is visually completely customizable, but has custom logic to publish events and manage it’s visual state based on events it has registered for.
When I say visually customizable, I mean I should be able to both create the button in xaml and set it’s style by binding to the supplied style. Or I can create an instance of the button and set the style by passing a parameter to an alternate constructor. Or by calling a method on the button class to set the style.
I do not plan on substituting the controls template, it should be a button. Can anyone point me to some code samples of this?
If you don’t want to allow the control to be templated (I would generally recommend you do, but you don’t have to) than a UserControl would work well. A simple user control that exposes a
ButtonStyleproperty that is applied to a specific control should solve your needs.