Silverlight – C# – How to set a XAML element’s style from code behind

XAMLelementName.Style = Application.Current.Resources["Style"] as Style;
// If your style is defined in App.xaml Application.Resources section
XAMLelementName.Style = this.Resources[StyleKey] as Style;
//  if your style is defined in Page.XAML UserControl.Resources section
XAMLelementName.Style = button.Resources[StyleKey] as Style;
// if your style is defined in the XAML as control.Resouces section
This entry was posted in C#, Knowledge Sharing, Silverlight, Troubleshooting. Bookmark the permalink.

2 Responses to Silverlight – C# – How to set a XAML element’s style from code behind

  1. Just wanted to say I love reading through your weblog and look forward to all your posts! Keep up the fantastic work!

  2. Wonderful paintings! That is the kind of information that are supposed to be shared across the internet. Shame on the seek engines for no longer positioning this post higher! Come on over and visit my web site . Thank you =)

Leave a Reply