0
votes

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?

2
"Visually completely customizable" and "I do not plan on substituting the controls template", which is it? It can't be both. - AnthonyWJones

2 Answers

0
votes

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 ButtonStyle property that is applied to a specific control should solve your needs.

0
votes

Totally depends on your application. I create ContentControl derivatives much more often than UserControl, if only for the glint of hope that they may be useful in the future.

I have written before:

UserControls are content controls that are optimized for simple design-time use, typically for sharing within an application, but not with other applications.

Component libraries should never contain UserControl implementations.