title: How to use resources defined in <Styles.Resources> inside Resource Dictionary
body: <p>I have a resource dictionary which is a datagrid style defined on it and a style inside that datagrid style.</p>
  <pre><code>&lt;Style TargetType=&quot;{x:Type DataGrid}&quot; x:Key=&quot;CatalogDataGrid&quot;&gt;
      &lt;Style.Resources&gt;
          &lt;Style TargetType=&quot;{x:Type DataGridCell}&quot; x:Key=&quot;RightAlignedDataGridCell&quot;&gt;
              &lt;Setter Property=&quot;Template&quot;&gt;
                  &lt;Setter.Value&gt;
                      &lt;ControlTemplate TargetType=&quot;{x:Type DataGridCell}&quot;&gt;
                          &lt;Border
                              Padding=&quot;5,0&quot;
                              BorderBrush=&quot;{TemplateBinding BorderBrush}&quot;
                              BorderThickness=&quot;{TemplateBinding BorderThickness}&quot;
                              Background=&quot;{TemplateBinding Background}&quot;
                              SnapsToDevicePixels=&quot;True&quot;&gt;
                              &lt;ContentPresenter
                              SnapsToDevicePixels=&quot;{TemplateBinding SnapsToDevicePixels}&quot;
                              VerticalAlignment=&quot;Center&quot;
                              HorizontalAlignment=&quot;Right&quot;/&gt;
                          &lt;/Border&gt;
                      &lt;/ControlTemplate&gt;
                  &lt;/Setter.Value&gt;
              &lt;/Setter&gt;
          &lt;/Style&gt;
      &lt;/Style.Resources&gt;
  &lt;/Style&gt;
  </code></pre>
  <p>Then in my XAML I tried to use <code>RightAlignedDataGridCell</code> so that my column be right aligned.</p>
  <pre><code>&lt;DataGrid... Style=&quot;{StaticResource CatalogDataGrid}&quot;&gt;
      &lt;DataGrid.Columns&gt;
          &lt;DataGridTextColumn Header=&quot;Name&quot; Binding=&quot;{Binding Name}&quot;&gt;
          &lt;/DataGridTextColumn&gt;
          &lt;DataGridTextColumn Header=&quot;Total&quot; Binding=&quot;{Binding Total}&quot;
                              CellStyle=&quot;{StaticResource RightAlignedDataGridCell}&quot;&gt;
          &lt;/DataGridTextColumn&gt;
      &lt;/DataGrid.Columns&gt;
  &lt;/DataGrid&gt;
  </code></pre>
  <p>When I run my app I received resource not found exception. If I put that style on resource dictionary root. It could work. But I want <code>RightAlignedDataGridCell</code> stays inside
  <code>&lt;Style.Resources&gt;</code> of <code>CatalogDataGrid</code>.</p>
  <p><strong>How to use that <code>RightAlignedDataGridCell</code> on my XAML without moving it to resource dictionary root?</strong></p>
  <p>Thanks in advance.</p>