2010-12-01 11 views
0

を実行します。WPFでのリソースの編集は、私がこの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> 

をし、私の質問は、私は背後にあるコードから赤にbtnStyleセッターの値を変更することができる方法ですか?

答えて

1

これは、あなたの質問に直接答えである:

var style = (Style) this.root.findResource("btnStyle"); 
style.Setters.Item[0].Value = Brushes.Red; 

しかし、あなたは正確に達成しようとしているの?

関連する問題