I am adding a new WPF project to an existing Visual Studio solution and would like to reuse a bunch of code (C # and xaml) from an existing project as part of the solution.
I created a new project and added existing files as follows:
- Right click project
- Add → Add Existing Item
- Locate the file for reuse, use the arrow next to "Add" and "Add as link"
Now I have a good project created with all the relevant links. However, XAML is choking on these links. For instance:
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary
Source="Resources\Elements\Buttons\Buttons.xaml" />
<ResourceDictionary
Source="Resources\Elements\TextBox\TextBox.xaml" />
</ResourceDictionary.MergedDictionaries>
The files "Buttons.xaml" and "TextBox.xaml" exist as links in my new project. The project is building, but when I start, I get the following XamlParseException:
The 'Resources \ Elements \ Buttons \ Buttons.xaml' value cannot be assigned to the Source property of the System.Windows.ResourceDictionary object. Cannot find the resource 'Resources / Elements / Buttons / buttons.xaml'.
The XAML parser seems to require that the actual copy of these XAML files exist in my new project, and not in the links.
This is exactly what I'm trying to avoid. I want my project to share these files, so that any changes are transferred to another project without searching and copying.
Any insight appreciated!