Reputation: 6446
I have this xaml:
<Grid x:Name="root">
<Grid.Resources>
<Style x:Key="btnStyle">
<Setter Property="Button.Background" Value="LightBlue"/>
</Style>
</Grid.Resources>
<Button Style="{DynamicResource btnStyle}"></Button>
</Grid>
and my question is how can I change the btnStyle setter value to Red from code behind?
Upvotes: 0
Views: 892
Reputation: 437336
This is the direct answer to your question:
var style = (Style) this.root.findResource("btnStyle");
style.Setters.Item[0].Value = Brushes.Red;
But what are you trying to accomplish exactly?
Upvotes: 1