title: WPF class library, loading XAML with absolute URI or relative URI both not working
body: <p>I'm programming a WPF class library mainly based on C# code and I'm currently trying to load XAML file only for styling UI Elements.</p>
  
  <p>Here is the XAML "style" code with "BuildAction : Content" :</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:WpfApplication1"&gt;
  &lt;Style x:Key="LabelStyle" TargetType="{x:Type Label}"&gt;
      &lt;Setter Property="Height" Value="53" /&gt;
      &lt;Setter Property="Width" Value="130" /&gt;
      &lt;Setter Property="HorizontalAlignment" Value="Left" /&gt;
      &lt;Setter Property="Margin" Value="99,71,0,0" /&gt;
      &lt;Setter Property="VerticalAlignment" Value= "Top" /&gt;
      &lt;Setter Property="Foreground" Value="#FFE75959" /&gt;
      &lt;Setter Property="FontFamily" Value="Calibri" /&gt;
      &lt;Setter Property="FontSize" Value="40" /&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p></p>
  
  <p>Here is the code for my label : </p>
  
  <pre><code>    private void CreateElement(int i)
      {
          UIElementOut[i] = new Label();
          var uiElement = (Label)UIElementOut[i];
          uiElement.HorizontalAlignment = HorizontalAlignment.Center;
          uiElement.VerticalAlignment = VerticalAlignment.Center;
          uiElement.FontFamily = new FontFamily(FFontInput[i]);
          uiElement.FontSize = Convert.ToDouble(FontSizeIn[i]);
          uiElement.Content = TextIn[i];
          Brush BgBrushColor = new SolidColorBrush(RGBAToMediaColor(FBgCol[i]));
          Brush FgBrushColor = new SolidColorBrush(RGBAToMediaColor(FFgCol[i]));
          uiElement.Background = BgBrushColor;
          uiElement.Foreground = FgBrushColor;
  
          Uri uri = new Uri("pack://application:,,,/WpfApplication1;component/WpfApplication1/Styles/LabelStyle.xaml", UriKind.Relative);
  
          StreamResourceInfo info = Application.GetContentStream(uri);
          System.Windows.Markup.XamlReader reader = new System.Windows.Markup.XamlReader();
          ResourceDictionary myResourceDictionary = Application.LoadComponent(uri) as ResourceDictionary;
          Application.Current.Resources.MergedDictionaries.Add(myResourceDictionary);
          Style myLabelStyle = myResourceDictionary["LabelStyle"] as Style;
          uiElement.Style = myLabelStyle;
      }
  </code></pre>
  
  <p>if UriKind is set to "Relative" I get this error message : </p>
  
  <pre><code>A relative URI cannot be created because the 'uriString' parameter represents an absolute URI.
  </code></pre>
  
  <p>But if Urikind is set to "Absolute" then I get this one :</p>
  
  <pre><code>Cannot use absolute URI.
  </code></pre>
  
  <p>So in both anyway, XAML file is not loaded and style is not applied.</p>
  
  <p>EDIT :</p>
  
  <p>I tried this URI :</p>
  
  <pre><code>pack://application:,,,/WpfApplication1;component/Styles/LabelStyle.xaml
  </code></pre>
  
  <p>And get the same error.</p>