title: Why doesn't (Style)Application.Current.Resources["FrameBorder"] let me access a resource in my ResourceDirectory
body: <p>I created a resource in the file <code>FrameRes.xaml</code> like this:</p>
  
  <pre><code>&lt;ResourceDictionary xmlns="http://xamarin.com/schemas/2014/forms" 
                      xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
                      x:Class="Japanese.Resources.FrameRes"&gt;
      &lt;Style x:Key="FrameBorder" TargetType="Frame"&gt;
          &lt;Setter Property="CornerRadius" Value="2" /&gt;
          &lt;Setter Property="HasShadow" Value="false" /&gt;
          &lt;Setter Property="Margin" Value="10,0" /&gt;
          &lt;Setter Property="BorderColor" Value="{DynamicResource LineColor}" /&gt;
          &lt;Setter Property="Padding" Value="0" /&gt;
          &lt;Setter Property="VerticalOptions" Value="Start" /&gt;
      &lt;/Style&gt;
  &lt;/ResourceDictionary&gt;
  </code></pre>
  
  <p>and this is contained inside:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;Application xmlns:converters="clr-namespace:Japanese" 
               xmlns="http://xamarin.com/schemas/2014/forms" 
               xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
               x:Class="Japanese.App"&gt;
      &lt;Application.Resources&gt;
          &lt;ResourceDictionary Source="/Resources/FooterRes.xaml" /&gt;
          &lt;ResourceDictionary Source="/Resources/FrameRes.xaml" /&gt;
      &lt;/Application.Resources&gt;
  &lt;/Application&gt;
  </code></pre>
  
  <p>When I try to access this in C# like this then it fails and says there's no reference to FrameBorder:</p>
  
  <pre><code>var fb2 = (Style)Application.Current.Resources["FrameBorder"];
  </code></pre>
  
  <p>When I try to access this in C# like this it works:</p>
  
  <pre><code>Application.Current.Resources.TryGetValue("FrameBorder", out object frameBorder);
  var fb = (Style)frameBorder;
  </code></pre>
  
  <p>Does anyone know why the first way doesn't work. It looks the same to me. </p>