Merging Resource Dictionaries Dynamically at Runtime (for Plugins)

I am using the Framework Managed Extensibility Framework for a WPF application. I have defined interfaces for the so-called extension points, which provide new features for the application.

Some of these functions may consist in displaying data using specific data templates, which you probably want to specify in the xaml resource file.

If I have one of these extension points (for example, plugins in a comprehensible language) defined in an assembly that is not known at compile time of the application, but I still want to combine the plugin resources with the application resources, how would I go about this?

All examples that show how to do this using the package URI notation state, which is the solution when the assemblies you reference are known at compile time. How do you achieve the same when you are not familiar with the assembly at compile time?

+3
source share
2 answers

You need to get either by code or by agreement - information that the resource dictionary will be combined. Details can be the name of the resource dictionary or the instance itself ResourceDictionary.

In the latter case, you have an instance ResourceDictionary, so you can simply combine it into your Application-level level (or any other level).

URI , ( extension.GetType().Assembly). ResourceDictionary, Source URI . , .

+4

, MEF ( ). SoapBox Core Views.

0

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


All Articles