Afternoon folks.
I have a .csproj file which contains some xaml resource dictionaries and a wpf application containing merged resource dictionaries, like the following:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/ComboBox.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
The resource dictionary is contained within the folder Resources/ and my csproj file contains relative links to all the files as follows:
<ApplicationDefinition Include="..\..\CodeFiles\WPF\App.xaml">
<Link>App.xaml</Link>
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="..\..\CodeFiles\WPF\Resources\ComboBox.xaml">
<Link>Resources\ComboBox.xaml</Link>
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="..\..\CodeFiles\WPF\MyPage.xaml">
<Link>MyPage.xaml</Link>
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="..\..\CodeFiles\WPF\App.xaml.cs">
<Link>App.xaml.cs</Link>
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="..\..\CodeFiles\WPF\MyPage.xaml.cs">
<Link>MyPage.xaml.cs</Link>
<DependentUpon>KinskyDesktop.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
The problem is that since my csproj file is located in a different directory from the "root" of the application's code, I get the resulting runtime error:
'Resources/ComboBox.xaml' value cannot be assigned to property 'Source' of object 'System.Windows.ResourceDictionary'. Cannot locate resource 'resources/combobox.xaml'.
Inspecting the outputted exe in reflector shows that the baml resources getting embedded within the exe are not named "Resources/xxxx.baml" - the Resources folder is stripped from the name and they end up as "xxxx.baml". Or, for example, if one puts the csproj file in a parent folder of the application source's root, the resources would end up something like "parent_folder/Resources/xxxx.baml". In other words, the embedded resources end up being dependent on the location of the csproj file.
My question then: is there a way of explicitly specifying the name of the generated xaml resources within the csproj file rather than relying on msbuild to name these based on the relative location of the csproj file to the code's root?
Regards
Iain Mcleod