forum

Home / DeveloperSection / Forums / How to change the window.resource style setter?

How to change the window.resource style setter?

Anonymous User 2919 26-Mar-2014
<Window.Resources >
        <Style x:Name="stylepropery" x:Key="BaseContentControlStyle" TargetType="{x:Type ContentControl}">
            <Setter Property="Foreground" Value="{DynamicResource MyFillBrush}"  />
        </Style>
        <Style  TargetType="{x:Type Label}" BasedOn="{StaticResource BaseContentControlStyle}" />
     <Style TargetType="{x:Type CheckBox}" BasedOn="{StaticResource BaseContentControlStyle}" />
    </Window.Resources>
which is applying common font color to all the labels and textboxes now i want to change the color of font from code behind but some how its not applying i just want to change setter propery value
 Setter setter = new Setter(ContentControl.ForegroundProperty, dt.Rows[0]["value"]);
 Style style = this.FindResource("BaseContentControlStyle") as Style;
 style.Setters.Add(setter);

I have used this but not succeeded.


wpf wpf 
Updated on 26-Mar-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By