title: How to bind colors in the style resource dictionary?
body: <p>I'm developing an Xamarin Forms application with a Portable Class Libraries (PCL).</p>
  
  <p>Always, I like to have resources into XAML files as sorted as possible. I have seen that it isn't possible create an XAML resource file directly. A solution for me is removing the App.cs file (on Portable project) and create a Forms Xaml Page as template. I have copied the code from the old App.cs to App.xaml.cs, and then I edited the xaml file.</p>
  
  <p>In the App.xaml file I have defined the color and also the style for a Label. When I bind the color into the style declaration, it fails in runtime.</p>
  
  <pre><code>&lt;Application xmlns="http://xamarin.com/schemas/2014/forms" 
           xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
           ...&gt;
  &lt;Application.Resources&gt;
  &lt;ResourceDictionary&gt;
  
    &lt;!-- LABELS --&gt;
    &lt;Style x:Key="labelProductReference" TargetType="Label" 
           BasedOn="{StaticResource labelBase}" &gt;
      &lt;Setter Property="FontSize" Value="22" /&gt;
      &lt;Setter Property="FontAttributes" Value="Bold" /&gt;
      &lt;Setter Property="HorizontalOptions" Value="StartAndExpand" /&gt;
      &lt;Setter Property="TextColor" Value="{StaticProperty textPrimaryColor}"
    &lt;/Style&gt;
  
     ...
  
    &lt;!-- COLORS --&gt;
    &lt;Color x:Key="textPrimaryColor"&gt;#FFFFFF&lt;/Color&gt;
  
     ...
  
   &lt;/ResourceDictionary&gt;
  &lt;/Application.Resources&gt;
  &lt;/Application&gt;
  </code></pre>
  
  <p>The error says: </p>
  
  <blockquote>
    <p>Xamarin.Forms.Xaml.XamlParseException: Position 45:38. StaticResource not found for key textPrimaryColor</p>
  </blockquote>
  
  <p>But If I bind the color where there are the Label into the page (MainPage.xaml), it works:</p>
  
  <pre><code>&lt;Label Text="{Binding Reference}" TextColor="{StaticResource textPrimaryColor}" 
                 Style="{StaticResource labelProductReference}" /&gt;
  </code></pre>
  
  <p>How I can set the color for a some control into the xaml style resource declaration?</p>