title: Styling Custom User Control Disabled state
body: <p>How can I style the 'disabled' state of my custom user control? I'm not clear on how to style the various parts of my custom user control. For example my custom user control is made up of several components. So How can I target specific parts of the control in my global style sheet? Keeping in mind that i want it to restore to it's original color if it's enabled again.</p>
  
  <p>Here is my custom user control code...</p>
  
  <p><strong>VNode.xaml</strong></p>
  
  <pre><code>&lt;UserControl x:Class="WpfApplication1.VNode"
               xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
               xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
               xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
               xmlns:local="clr-namespace:WpfApplication1"
               mc:Ignorable="d" 
               d:DesignHeight="100" d:DesignWidth="200"&gt;
      &lt;Grid&gt;
          &lt;Rectangle x:Name="Backplate" Fill="Green" Width="100" Height="50" RadiusX="3" RadiusY="3"/&gt;
          &lt;Rectangle x:Name="Highlight"
                     Height="60"
                     Width="110" 
                     Fill="Transparent"
                     Stroke="White"
                     StrokeThickness="2"
                     RadiusX="6" RadiusY="6"&gt;
          &lt;/Rectangle&gt;
          &lt;TextBlock x:Name="Label" Text="Label" TextWrapping="Wrap" Width="100" Height="50"/&gt;
      &lt;/Grid&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p><strong>VNode.xaml.cs</strong></p>
  
  <pre><code>using System.Windows.Controls;
  using System.Windows.Media;
  
  namespace WpfApplication1
  {
      /// &lt;summary&gt;
      /// Interaction logic for VNode.xaml
      /// &lt;/summary&gt;
      public partial class VNode : UserControl
      {
          public VNode()
          {
              InitializeComponent();
          }
          public Brush BackplateColor
          {
              get { return Backplate.Fill; }
              set { Backplate.Fill = value; }
          }
          public string Text
          {
              get { return Label.Text; }
              set { Label.Text = value; }
          }
      }
  }
  </code></pre>
  
  <p><strong>Style sheet</strong></p>
  
  <pre><code>&lt;ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                      xmlns:local="clr-namespace:WpfApplication1"&gt;
  
      &lt;Style x:Key="NodeStyle" TargetType="{x:Type local:VNode}"&gt;
          &lt;Style.Triggers&gt;
              &lt;Trigger Property="IsEnabled" Value="False"&gt;
                  &lt;Setter Property="Backplate" Value="Red" /&gt;
              &lt;/Trigger&gt;
          &lt;/Style.Triggers&gt;
      &lt;/Style&gt;
  
  &lt;/ResourceDictionary&gt;
  </code></pre>