[WPF learning] 3. User Control Library to use resources confused dictionary

Project requires (needs or front end of the separation), I used the front end user control library, and the control code is loaded by the backend.

However, the user can not control library designated resource dictionary, so in xaml file manually add a user control inside a resource dictionary

    <UserControl.Resources>
        <ResourceDictionary Source="/d1.xaml"/>
    </UserControl.Resources>
    <Grid>
        <TextBlock FontSize="{DynamicResource FontSizeL}" Text="Hello"/>
    </Grid>

Facilitate the design stage, to generate dll, when the main program is called, on the error, saying the absence of the resource file (d1.xaml), after research Pack Url understand that there are two solutions:

  1. Introducing the resource file in the corresponding position of the main program, the above needs have a code in the main program file d1.xaml below the root directory
  2. Modify Source
        <ResourceDictionary Source="pack://application:,,,/程序集名称;component/d1.xaml"/>

If only one resource dictionary, be solved.

Now the project needs multiple languages ​​to English, Chinese, Thai is a need to import dynamic resource dictionaries as needed, dizzy.

The current solution is to pull the design phase of the resource file in, manually add, before compiling the <UserControl.Resources> Delete, it is troublesome, do not know there is no more convenient way.

Guess you like

Origin www.cnblogs.com/catzhou/p/12377482.html