Change disabled background color(to GRAY) of TextBox in WPF

<Windows.Resources>
 <SolidColorBrush x:Key="DisabledForegroundBrush" Color="Red" />
 <SolidColorBrush x:Key="DisabledBackgroundBrush" Color="White" />
 <Style TargetType="{x:Type TextBox}">
 <Style.Triggers>
 <Trigger Property="IsEnabled" Value="False">
 <Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}" />
 <Setter Property="Background" Value="{StaticResource DisabledBackgroundBrush}" />
 </Trigger>
 </Style.Triggers>
 </Style>
</Windows.Resources>

If You need to apply it for all the textbox controls, use the above code. For specific textbox, just set the key and apply the style to that Textbox.

 

Advertisements
By Sriramjithendra Posted in WPF

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s