---
title: "How to change the window.resource style setter?"  
description: "How to change the window.resource style setter?"  
author: "Anonymous User"  
published: 2014-03-26  
updated: 2014-03-26  
canonical: https://www.mindstick.com/forum/1989/how-to-change-the-window-resource-style-setter  
category: "wpf"  
tags: ["wpf"]  
reading_time: 1 minute  

---

# How to change the window.resource style setter?

```
<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.

## Replies

### Reply by Pravesh Singh

Hi Tanuj,\

Try this code this may help you

Style style = new Style(typeof(ContentControl));

style.Setters.Add(new Setter(ContentControl.ForegroundProperty, Brushes.Green)); Resources["BaseContentControlStyle"] = style;


---

Original Source: https://www.mindstick.com/forum/1989/how-to-change-the-window-resource-style-setter

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
