I am creating a Control Template for the Button control in Silverlight 2. I started with an empty template and added the visual elements I wanted. The main visual element is just a path (shape) filled with a color. The button control already has a Color property associated with it and I was wondering if it was possible to link the Color property of the button control with the Color property of the path inside my template? It just seems pointless to have a Color property on the Button that actually has no effect on the button.
My actual goal in my application is to have this button available in 4 different colors and the only options I can think of so far are 4 distinct templates or writing a new control that inherits from Button and neither of these solutions seem like they're taking advantage of the idea of Control templating.
-
It's possible Silverlight doesn't have it available but you should be able to use templatebinding:
<Path Fill="{TemplateBinding BackgroundColor}" />
Then you can use
<Button Background="Blue" /> <Button Background="Red" /> <Button Background="Green" /> <Button Background="Yellow" />
HTH
0 comments:
Post a Comment