Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

WPF Resource Dictionary with code behind file can’t be found by using a separated assembly

$
0
0

Hello,

I have the assembly "WpfStyle.dll" where I put all my WPF styles for my main app and It works as expected, but as soon as I add a code behind file to the XAML of the ResourceDictionary, the following error is thrown: "An error occurred while finding the resource dictionary".

Note: I get the issue only when I add the "WpfStyle.dll" as assembly reference. If I add it as projectreference all works fine.

Here below, some others info about the "WpfStyle.dll" structure:

1) "WindowStyle.xaml" and "WindowStyle.xaml.cs" files are placed in "Themes" subfolder

2) Here below a piece of code of the ResourceDictionary file ("WindowStyle.xaml"):

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    x:Class="WpfStyle.Themes.WindowStyle">

...

</ResourceDictionary>


3) Here below a piece of code behind ("WindowStyle.xaml.cs"):

namespace WpfStyle.Themes
{
  public partial class WindowStyle : ResourceDictionary
  {
    public WindowStyle()
    {
      InitializeComponent();
    }

   ...

  }
}


4) Here below the App.xaml of the main app that throws the error:

<Application x:Class="WpfApplication1.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml"><Application.Resources><ResourceDictionary><ResourceDictionary.MergedDictionaries>                <ResourceDictionary Source="pack://application:,,,/WpfStyle;component/Themes/WindowStyle.xaml"/></ResourceDictionary.MergedDictionaries></ResourceDictionary></Application.Resources></Application>

What am I doing wrong?





Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>