Skip to main content
Home Forums Silverlight Programming Silverlight Controls and Silverlight Toolkit Accessing a style defined in xaml in the code behind.
1 replies. Latest Post by sasideva on November 7, 2009.
(0)
somethin...
Member
6 points
34 Posts
11-07-2009 2:03 AM |
Hi,
I've defined a style for a listboxitem in xaml and i need to apply this style in codebehind. This is what I've tried:
xaml:
xaml.cs:
listbox.ItemContainerStyle = draggableItemStyle;
The dragable style on the listbox doesnt seem to work. Is this the correct way of doing it or is there another way?
Any help would really be appreciated.
Thanks and regards,
sasideva
240 points
58 Posts
11-07-2009 3:28 AM |
button.Style = Application.Current.Resources["TopMenuItemButton"] as Style; // If your style is defined in App.xaml Application.Resources section button.Style = this.Resources[StyleKey] as Style; // if your style is defined in Page.XAML UserControl.Resources section button.Style = button.Resources[StyleKey] as Style; // if your style is defined in the XAML as control.Resouces section