title: In WPF, why does my Style in Generic.xaml not get applied to my Custom Control?
body: <p>In WPF, I have a custom control that inherits from TreeView. The code is as follows...</p>
  
  <pre><code>public class CustomTRV : TreeView
  {
      static CustomTRV()
      {
          //Removed this because I want the default TreeView look.
          //......CustomTRV.DefaultStyleKeyProperty.OverrideMetadata(typeof(CustomTRV), new FrameworkPropertyMetadata(typeof(CustomTRV)));
      }
  
      public void Connect(string entityHierarchyToken)
      {
          //build viewModel classes... 
          this.ItemsSource = new List&lt;ViewModel&gt;()
          {
              new ViewModel() { TextValue = "aaaa" },
              new ViewModel() { TextValue = "bbb" },
              new ViewModel() { TextValue = "ccc" },
              new ViewModel() { TextValue = "ddd" },
              new ViewModel() { TextValue = "eee" },
          };
      }
  }
  </code></pre>
  
  <p>The content in Generic.xaml looks as follows...</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:WpfTestCustomControl"&gt;
  
      &lt;HierarchicalDataTemplate DataType="{x:Type local:ViewModel}"&gt;
          &lt;TextBlock Foreground="Blue" Text="{Binding Path=TextValue}"&gt;&lt;/TextBlock&gt;
      &lt;/HierarchicalDataTemplate&gt;
  
      &lt;Style TargetType="{x:Type local:CustomTRV}"&gt;
          &lt;Setter Property="ItemContainerStyle"&gt;
              &lt;Setter.Value&gt;
  
                  &lt;Style TargetType="{x:Type TreeViewItem}"&gt;
                      &lt;Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" /&gt;
                      &lt;Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" /&gt;
                      &lt;Setter Property="FontWeight" Value="Bold" /&gt;
                      &lt;Style.Triggers&gt;
                          &lt;Trigger Property="IsSelected" Value="True"&gt;
                              &lt;Setter Property="FontWeight" Value="Normal" /&gt;
                          &lt;/Trigger&gt;
                      &lt;/Style.Triggers&gt;
                  &lt;/Style&gt;
  
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
  &lt;/ResourceDictionary&gt;
  </code></pre>
  
  <p>I thought the Generic.xaml code should get applied to my control, and as such the ItemContainer property value should be set. But it looks like the ItemContainerStyle does not have any effect whatsoever.</p>
  
  <p>NOTE: the HierarchicalDataTemplate from Generic.xaml DOES work ok, so the file is being interpreted.</p>
  
  <p>Any ideas?</p>