Silverlight Template Color Properties

I am creating a control template for a Button control in Silverlight 2. I started with a blank template and added the visuals that I wanted. The main visual is simply a path (shape) filled with color. The control button already has a Color property associated with it and I was wondering if it is possible to bind the Color property of the Button control to the Path Color property inside my template? It just seems pointless to have a Color property on a button that doesn't actually affect the button.

My actual goal in my application is for this button to be available in 4 different colors and the only options I can imagine so far are 4 different templates or writing a new control that inherits from Button and none of these solutions it doesn't seem like they're taking advantage of the idea of ​​control patterns.

+1


source to share


1 answer


Silverlight may not have it available, but you can use templatebinding:

<Path Fill="{TemplateBinding BackgroundColor}" />

      

Then you can use



<Button Background="Blue" />
<Button Background="Red" />
<Button Background="Green" />
<Button Background="Yellow" />

      

NTN

+3


source







All Articles