Skip to main content
Home Forums Silverlight Programming Silverlight Controls and Silverlight Toolkit Theming. Two Button Styles. How?
5 replies. Latest Post by maxima120 on July 2, 2009.
(0)
maxima120
Member
88 points
85 Posts
07-02-2009 9:03 AM |
Hi
I have few different styles for buttons. Say ButtonStyle1 and ButtonStyle2. And I use them <Button Style="{StaticResource ButtonStyle1...
I would like to add theming to my application. So the ButtonStyle1 could be of different colours.
I could manage to use implicit style manager in a prototype to apply different themes at runtime using code:
ImplicitStyleManager.SetResourceDictionaryUri(this, uri); ImplicitStyleManager.SetApplyMode(this, ImplicitStylesApplyMode.Auto); ImplicitStyleManager.Apply(this);
However the manager applies by type. If there is a style with target type = Button it will be applied to a button control.
How can I use toolkit theming to have different styles within different themes. Say ThemeOrange.ButtonStyle1 and 2; ThemeGreen.ButtonStyle1 and 2
Thank you
ken tucker
All-Star
16276 points
2,479 Posts
07-02-2009 12:45 PM |
Maybe create a class named OtherButtonStyle and have it inherit from button. Add a theme in this type. Use an OtherButtonStyle control in your form instead of a button where you need the other style. (untested)
07-02-2009 12:57 PM |
it makes sense. I am going to test and report.
Should work I suppose (if toolkit manager will not override my efforts :))
Thank you!
07-02-2009 1:28 PM |
OK, it doesnt work out of the box, ImplicitStyleManager throws silent exception "Invalid attribute value local:Button1 for property TargetType"
It seems I need to roll the sleeves and dig into the manager code to make it load my types somehow...
07-02-2009 2:05 PM |
Update. I could manage to load my new Button1 type but ImplicitStyleManager still doesnt work. No exceptions just no effect.
element.SetValue(ExternalResourceDictionaryProperty, value); <-- this doesnt make visual difference
07-02-2009 7:06 PM |
would be there another suggestions? Am I the only one who need it?