title: WPF Style Resource not Working
body: <p>All, I want to inherit a generic style for all <code>DataGrid/ResourceDataGrid</code>s in my application. To do this I have created a resource file called <code>ResourceControl.xaml</code>, in which I have </p>
  
  <pre><code>&lt;UserControl x:Class="ResourceStudio.Views.ResourceControl"
               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:viewModels="clr-namespace:ResourceStudio.ViewModels" 
               xmlns:dataAccess="clr-namespace:ResourceStudio.DataAccess" 
               xmlns:controls="clr-namespace:ResourceStudio.Controls"
               mc:Ignorable="d"&gt;
     &lt;UserControl.Resources&gt;
        &lt;ResourceDictionary&gt;
           &lt;ResourceDictionary.MergedDictionaries&gt;
              &lt;ResourceDictionary Source="MainWindowResources.xaml" /&gt;
           &lt;/ResourceDictionary.MergedDictionaries&gt;
        &lt;/ResourceDictionary&gt;
     &lt;/UserControl.Resources&gt;
     &lt;DockPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch"&gt;
        &lt;TextBox DockPanel.Dock="Top" 
                 Name="searchBox" 
                 Margin="0,2" 
                 VerticalContentAlignment="Center"
                 mahAppsControls:TextboxHelper.Watermark="Search Resources" 
                 mahAppsControls:TextboxHelper.ClearTextButton="True"&gt;
        &lt;/TextBox&gt;
        &lt;Grid DockPanel.Dock="Top"&gt;
           &lt;controls:ResourceDataGrid x:Name="resourceDataGrid" 
                                      ItemsSource="{Binding Path=Resources}" 
                                      dataAccess:DataGridTextSearch.SearchValue="{Binding ElementName=searchBox, Path=Text, UpdateSourceTrigger=PropertyChanged}" 
                                      dataAccess:DataGridTextSearch.IsAnyTextMatch="False"
                                      HorizontalAlignment="Stretch" 
                                      VerticalAlignment="Stretch" 
                                      AutoGenerateColumns="False" 
                                      GridLinesVisibility="None"
                                      RowHeaderWidth="0" 
                                      CanUserAddRows="True" 
                                      CanUserDeleteRows="True"&gt;
              &lt;controls:ResourceDataGrid.Columns&gt;
                 &lt;DataGridTextColumn Header="KeyIndex" Binding="{Binding KeyIndex}" IsReadOnly="True"/&gt;
                 &lt;DataGridTextColumn Header="FileName" Binding="{Binding FileName}" IsReadOnly="True"/&gt;
                 &lt;DataGridTextColumn Header="ResourceName" Binding="{Binding ResourceName}" IsReadOnly="False"/&gt;
                 &lt;controls:CollectionTextColumn Collection="ResourceStringList" Visibility="Collapsed"/&gt;
              &lt;/controls:ResourceDataGrid.Columns&gt;
              &lt;controls:ResourceDataGrid.Resources&gt;
                 &lt;dataAccess:SearchValueConverter x:Key="searchValueConverter"/&gt;
                 &lt;Style TargetType="{x:Type DataGridCell}"&gt;
                    &lt;Setter Property="dataAccess:DataGridTextSearch.IsTextMatch"&gt;
                       &lt;Setter.Value&gt;
                          &lt;MultiBinding Converter="{StaticResource searchValueConverter}"&gt;
                             &lt;Binding RelativeSource="{RelativeSource Self}" Path="Content.Text" /&gt;
                             &lt;Binding RelativeSource="{RelativeSource Self}" Path="(dataAccess:DataGridTextSearch.SearchValue)" /&gt;
                             &lt;Binding ElementName="resourceDataGrid" /&gt;
                          &lt;/MultiBinding&gt;
                       &lt;/Setter.Value&gt;
                    &lt;/Setter&gt;
                    &lt;Style.Triggers&gt;
                       &lt;Trigger Property="dataAccess:DataGridTextSearch.IsTextMatch" Value="True"&gt;
                          &lt;Setter Property="Background" Value="Orange" /&gt;
                       &lt;/Trigger&gt;
                    &lt;/Style.Triggers&gt;
                 &lt;/Style&gt;
              &lt;/controls:ResourceDataGrid.Resources&gt;
           &lt;/controls:ResourceDataGrid&gt;
        &lt;/Grid&gt;
     &lt;/DockPanel&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>Where in the resource file <code>MainWindowResources.xaml</code> I have </p>
  
  <pre><code>&lt;!--DataGrid Style--&gt;
  &lt;Style TargetType="{x:Type DataGrid}"&gt;
     &lt;Setter Property="Background" Value="White"/&gt;
     &lt;Style.Triggers&gt;
        &lt;Trigger Property="IsSelected" Value="True"&gt;
           &lt;!--&lt;Setter Property="Background" Value="{DynamicResource AccentColor}"/&gt;--&gt;
           &lt;Setter Property="Background" Value="Red"/&gt;
           &lt;Setter Property="Foreground" Value="White"/&gt;
        &lt;/Trigger&gt;
     &lt;/Style.Triggers&gt;
  &lt;/Style&gt;
  
  &lt;!--ResourceDataGrid Style--&gt;
  &lt;Style TargetType="{x:Type controls:ResourceDataGrid}"&gt;
     &lt;Setter Property="Background" Value="White"/&gt;
     &lt;Style.Triggers&gt;
        &lt;Trigger Property="IsSelected" Value="True"&gt;
           &lt;!--&lt;Setter Property="Background" Value="{DynamicResource AccentColor}"/&gt;--&gt;
           &lt;Setter Property="Background" Value="Red"/&gt;
           &lt;Setter Property="Foreground" Value="White"/&gt;
        &lt;/Trigger&gt;
     &lt;/Style.Triggers&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>But my <code>ResourceDataGrid</code> is not inheriting the style that is defined in the <code>MainWindowResources.xaml</code>, why?</p>