I have two separate WPF projects, each with their own defined Dynamic Resources which mostly defines colors in each application. The task at hand is to include the main pages from each project in a new project. So far the projects are both included, but the Dynamic Resources are used from the new project.
Can I make sure that pages from each project will use the Dynamic Resources from their own project, instead of using the resources from the executing project?
Example of the issue:
The GreenPage.xaml and application.xaml from the old application:
<Page x:Class="GreenPage"
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="GreenPage">
<Grid Background="{DynamicResource DefinedColor}">
</Grid>
</Page>
<Application x:Class="Application"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Test"
StartupUri="MainWindow.xaml">
<Application.Resources>
<SolidColorBrush x:Key="DefinedColor" Color="Green"/>
</Application.Resources>
</Application>
The GreenPage is green when I expect it in the designer, however, when inserting the page in a window in another project, the background is not green anymore:
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:NewProject"
xmlns:test="clr-namespace:Test;assembly=Test"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<test:GreenPage/>
</Window>