WPF / Prism: how do I make a resource in my main application leak into user control contained in a separate assembly?

I have the following:

MainApp - Build 1 (Contains UserContolA) - Build 2 (Contains UserControlB) - Etc.

Not every assembly will be loaded, so

No assembly can compile if I try to assign resources to the controls (button, combobox, etc.) that it cannot find, because I want my MainApp to dictate these resources. But, if I include resources in assemblies, it seems that I can not redefine them (since WPF goes from bottom to top for resources giving prioroty to those closest to the bottom).

In addition, I’m afraid, even if I really solve this problem, trying to make it dynamic, so that the user can choose from different β€œthemes” that would make it even more difficult.

I included a prism in this topic because I plan to use it as my structure, but I did not look deep enough into it to see if it affects it in any way or if something is built into it that would be divine.

+3
source share
1 answer

, , WPF . . . , , . , Themes\Generic.xaml . , , .

, , :

, Generic.xaml :

[assembly: ThemeInfo(
    ResourceDictionaryLocation.None,
    ResourceDictionaryLocation.SourceAssembly)]

Edit:

, UserControl. UserControl , , :

  • {DynamicResource ...} UserControl.

, , , , UserControl. :

  • Expression Blend " ". , , Blend , .
  • Visual Studio UserControl XAML.

Visual Studio UserControl :

<UserControl.Resources>
    <ResourceDictionary Source="/YourControlLibrary;component/DesignTimeResources.xaml"/>
</UserControl.Resources>

, XAML. , Visual Studio , , .

+1

Source: https://habr.com/ru/post/1784203/


All Articles