Skip to main content

Microsoft Silverlight

Unanswered Question Theming. Two Button Styles. How?RSS Feed

(0)

maxima120
maxima120

Member

Member

88 points

85 Posts

Theming. Two Button Styles. How?

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
ken tucker

All-Star

All-Star

16276 points

2,479 Posts

Re: Theming. Two Button Styles. How?

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)

maxima120
maxima120

Member

Member

88 points

85 Posts

Re: Re: Theming. Two Button Styles. How?

it makes sense. I am going to test and report. 

Should work I suppose (if toolkit manager will not override my efforts :))

 Thank you!

maxima120
maxima120

Member

Member

88 points

85 Posts

Re: Re: Re: Theming. Two Button Styles. How?

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...

maxima120
maxima120

Member

Member

88 points

85 Posts

Re: Re: Re: Re: Theming. Two Button Styles. How?

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

maxima120
maxima120

Member

Member

88 points

85 Posts

Re: Re: Re: Re: Theming. Two Button Styles. How?

would be there another suggestions? Am I the only one who need it?

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities