title: Visual Studio 2019 WPF designer won't display custom controls
body: <p>In a WPF (.NET Core) application project I have defined a folder to contain all custom controls (both class definitions and UI style .xaml files, each custom control has a pair of these files). When using these custom controls in the same assembly, I associate the default style to the custom control by merging all UI styles in the /Themes/Generic.xaml shown below</p>
  <pre><code>&lt;ResourceDictionary.MergedDictionaries&gt;
      &lt;ResourceDictionary Source=&quot;/CustomControl/SomeCustomControlStyle.xaml&quot; /&gt;
      &lt;!-- Similarly list all other custom control xaml files --&gt;
  &lt;/ResourceDictionary.MergedDictionaries&gt;
  </code></pre>
  <p>For each custom control the corresponding xaml defines its style without <code>x:Key</code> as follows</p>
  <pre><code>&lt;Style TargetType=&quot;{x:Type SomeCustomControl}&quot; &gt;
      &lt;Setter Parameter=&quot;Template&quot;&gt;
          &lt;Setter.Value&gt;
              &lt;ControlTemplate TargetType=&quot;{x:Type SomeCustomControl}&quot;&gt;
                  &lt;!-- UI Definitions --&gt;
              &lt;/&lt;ControlTemplate&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>
  <p>All custom control derives from <code>Control</code> and contains a static constructor with</p>
  <pre><code>DefaultStyleKeyProperty.OverrideMetadata(typeof(SomeCustomControl), 
                  new FrameworkPropertyMetadata(typeof(SomeCustomControl)));
  </code></pre>
  <p>The project build successfully and the custom controls are shown when application is running. However Visual Studio designer is unable to display any custom controls and reporting an error</p>
  <pre><code>XDG0062 Cannot locate resource 'customcontrols/somecustomcontrol.xaml'.
  </code></pre>
  <p>I have tried to move the default style from individual .xaml files to Generic.xaml and the problem can be solved. However I have quite a few custom controls and using a single Generic.xaml to define all the UI is not very ideal. But not be able to see UI elements in designer is also very inconvenient.
  Am I missing something? Is it a Visual Studio bug? Are there any walkarounds?</p>
  <p>Thanks!</p>