Question: I have problem with changing color of disabled textbox. I have already 'foreground' property for my textbox when it is enabled. But I want to set another color when it is disabled. How can I achieve this?

---

@Harry

It's nothing special

XML

```
 <TextBox x:Name="txt1" HorizontalAlignment="Left" Margin="98,185,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="160" IsEnabled="False" Background="Blue" />

 <Button x:Name="btn1" Content="Button" HorizontalAlignment="Left" Margin="98,271,0,0" VerticalAlignment="Top" Click="btn1_Click"/>

```

CS:

```
  private void btn1_Click(object sender, RoutedEventArgs e)
    {

        txt1.IsEnabled = true;

    }

```

By default txt1 is disabled and has grey color. I want change this color.

I can operate only on colors of enabled texbox. Now is set to 'blue'

Answer: 
Just edit [the Style](https://msdn.microsoft.com/en-us/library/windows/apps/mt299154.aspx) of your *TextBox* - you will find there *VisualState* responsible for changes when control is disabled. You can change foreground, background, border - anything you want. A sample with background color changed to red:

```xml
<VisualStateManager.VisualStateGroups>
    <VisualStateGroup x:Name="CommonStates">
        <VisualState x:Name="Disabled">
            <Storyboard>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="HeaderContentPresenter">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlDisabledBaseMediumLowBrush}"/>
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="BackgroundElement">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="Red"/>
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="BorderElement">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlBackgroundBaseLowBrush}"/>
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="BorderElement">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlDisabledBaseLowBrush}"/>
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentElement">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlDisabledChromeDisabledLowBrush}"/>
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="PlaceholderTextContentPresenter">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlDisabledChromeDisabledLowBrush}"/>
                </ObjectAnimationUsingKeyFrames>
            </Storyboard>
        </VisualState>

```
You need to check when button is disabled then set the colour to what you need. so something like this 

```
if(txt1.IsEnabled == true){
  //enable colour
}else{
  //set disable colour
}

```

OR 

You can also set the colour inthe form load function.

so in the form load method set the colour.

```
txt1.button1.BackColor = Color.Red; 

```

or forecolor

```
txt1.ForeColor = System.Drawing.Color.Red

```

Along these lines.