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

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

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.


By Sriramjithendra Posted in WPF

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s