title: MaterialDesignXamlToolkit with WPF class library?
body: <p>Sorry for the duplicate, but my low reputation does not allow me to comment on posts.</p>
  
  <p>i am trying to use MaterialDesignXamlToolkit with WPF with class library, exactly as in this post: <a href="https://stackoverflow.com/questions/55594443/how-to-include-materialdesignxamltoolkit-to-wpf-class-library">How to include MaterialDesignXamlToolkit to WPF class library?</a></p>
  
  <p>-so i installed Material Design nuGet and added ResourceDictionary named MaterialDesign.xaml, where I copied and paste this code:</p>
  
  <pre><code>&lt;ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt;
      &lt;ResourceDictionary.MergedDictionaries&gt;
          &lt;ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" /&gt;
          &lt;ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" /&gt;
          &lt;ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.DeepPurple.xaml" /&gt;
          &lt;ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml" /&gt;
      &lt;/ResourceDictionary.MergedDictionaries&gt;
  </code></pre>
  
  <p></p>
  
  <p>then I created a new WPF page where I added Resource, so my xaml looks like this:</p>
  
  <pre><code>&lt;Page x:Class="test.Page1"
    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:local="clr-namespace:test"
    mc:Ignorable="d" 
    d:DesignHeight="450" d:DesignWidth="800"
    Title="Page1"
  
    xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
    TextElement.Foreground="{DynamicResource MaterialDesignBody}"
    TextElement.FontWeight="Regular"
    TextElement.FontSize="13"
    TextOptions.TextFormattingMode="Ideal"
    TextOptions.TextRenderingMode="Auto"
    Background="{DynamicResource MaterialDesignPaper}"
    FontFamily="{DynamicResource MaterialDesignFont}"&gt;
  &lt;Page.Resources&gt;
      &lt;ResourceDictionary Source="/MyAsembly;component/ResourceDictionary/MaterialDesign.xaml" /&gt;
  &lt;/Page.Resources&gt;
  
  &lt;Grid&gt;
      &lt;materialDesign:Card Padding="32" Margin="16"&gt;
          &lt;TextBlock Style="{DynamicResource MaterialDesignTitleTextBlock}"&gt;My First Material Design App&lt;/TextBlock&gt;
      &lt;/materialDesign:Card&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>Of course I got an error: <strong>The resource {MaterialDesignBody, MaterialDesignPaper, MaterialDesignFont} could not be resolved</strong></p>
  
  <p>as <em>@Marija Rakic</em> mentions in the post, I dried to add dummy lines to my Page1.xaml.cs class</p>
  
  <pre><code>using MaterialDesignColors;
  using MaterialDesignThemes.Wpf;
  using System.Windows.Controls;
  
  
  namespace test
  {
      /// &lt;summary&gt;
      /// Interaction logic for Page1.xaml
      /// &lt;/summary&gt;
      public partial class Page1 : Page
      {
          public Page1()
          {
              ColorZoneAssist.SetMode(new GroupBox(), ColorZoneMode.Accent);
              Hue hue = new Hue("name", System.Windows.Media.Color.FromArgb(1, 2, 3, 4), System.Windows.Media.Color.FromArgb(1, 5, 6, 7));
              InitializeComponent();
          }
      }
  }
  </code></pre>
  
  <p>but it didn't help. The error was still there. So I tried <em>@Trygve</em> solution and created one more class named MaterialDesign.xaml.cs where I added an assembly</p>
  
  <pre><code>using System.IO;
  using System.Reflection;
  using System.Windows;
  
  namespace test
  {
      partial class MaterialDesign: ResourceDictionary
      {
          public MaterialDesign() {
              Assembly.LoadFrom(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "MaterialDesignThemes.Wpf.dll"));
              Assembly.LoadFrom(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "MaterialDesignColors.dll"));
              InitializeComponent();
          }
      }
  }
  </code></pre>
  
  <p>and added a reference to MaterialDesign.xaml:</p>
  
  <pre><code>x:Class="test.MaterialDesign"
  </code></pre>
  
  <p>but it also didn't work and mentioned error is still there.I don't know where I'm making a mistake ..</p>