I have several ResourceDictionaries
in my application to make it localizable. These files are named smelling like Language_en.xaml, Language_nl.xaml, etc. An example of such a file is given below.
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<!-- DO NOT LOCALIZE -->
<system:String x:Key="Language">English</system:String>
<FlowDirection x:Key="FlowDirection">LeftToRight</FlowDirection>
<!-- DO LOCALIZE -->
<system:String x:Key="Title">English Title External</system:String>
</ResourceDictionary>
To load these files when the application is running I create the paths like this:
_appResDicSource = Path.Combine("\\" + _projectName + ";component", _languagesDirectoryName,
_fileBaseName + "_" + language + ".xaml");
_clsLibResDicSource = "\\MyDLL;component\\Languages\\Language_" + language + ".xaml";
The above is working for both Build Actions Resource
and Page
with the CtOD set to "Do not copy" and Custom Tool set to "MSBuild:Compile".
From this link I learned the quote below, but what is the best thing for my project?
Resource (wpf only): embeds the file in a shared (by all files in the assembly with similar setting) assembly manifest resource named AppName.g.resources.
Page (wpf only): Used to compile a xaml file into baml. The baml is then embedded with the same technique as Resource (i.e. available as `AppName.g.resources)