Skip to main content
Microsoft Silverlight
Home Forums Silverlight Design Designing with Silverlight Load Resource Dictionalry dynamically
1 replies. Latest Post by Thomas Claudius Huber on February 9, 2010.
(0)
diptidja...
Member
0 points
1 Posts
02-09-2010 8:42 AM |
Hello,
I want to load resource dictionary file dynamically.
For eg. I have textbox and i want to set its backgroup color dynamically from resource file.
in Test.xaml page:
<TextBox Text="Hello World" Style="{StaticResource HeaderTextblock}"></TextBox>
In Resource Dictionary 1: Blue.xaml
<Style x:Name="HeaderTextblock" TargetType="TextBox"> <Setter Property="Background" Value="Blue" /> </Style>
In Resource Dictionary 2: Red.xaml
<Style x:Name="HeaderTextblock" TargetType="TextBox"> <Setter Property="Background" Value="Red" /> </Style>
Already resource dictionary loaded as "Blue.xaml"
and on button click i want to load "Red.xaml" so that textbox color will change as red.
Please suggest any way to do this.
Thomas C...
Contributor
7497 points
1,108 Posts
02-09-2010 9:16 AM |
Hi dipti,
you should look at the XamlReader-class and its Load-Method. But by the way, the StaticResource-Markup-Extension won't recognize any changes. It's just an initialization, but no binding (WPF contains another extension called DynamicResource. That one isn't available in Silverlight, so you've to refresh manually).