How to get the ResourceDictionary style when it is loaded from external xap and assemblies, MEF is served?

I have the following setup:

The main application loads XAP with the implementation of IPlugin. The plugin contains a "DisplayPanel" containing a reference control with other controls. The DisplayPanel here is just a container control for displaying a reference control.

This reference control from the assembly uses the style from the ResourceDictionary xaml in this assembly. At least what I want to have. The problem is that the reference control is causing an error:

Cannot find resource with name / key PlayerPanelGrad [Line: 1500 Position: 127]

I tried to get the style by referencing theResourceDictionary through a Merged Resource dictionary link:

       <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="TableControls;component/ControlsStyle.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>

.

?

+3
4

: ( ) InitializeComponent:

public ActionPanel()
{
     StreamResourceInfo sr = Application.GetResourceStream(
          new Uri("TableControls;component/ControlsStyle.xaml", UriKind.Relative));
     Application.Current.Resources.Add("plop",sr.Stream);
     // Required to initialize variables
     InitializeComponent();
}
+1
0

// other.dll, :

       StreamResourceInfo srf = Application.GetResourceStream(new Uri("otherdll;component/Resources/Brush.xaml", UriKind.Relative));

        StreamReader sr = new StreamReader(srf.Stream);
        string stt = sr.ReadToEnd();
        ResourceDictionary dict = XamlReader.Load(stt) as ResourceDictionary;
        Application.Current.Resources.MergedDictionaries.Add(dict);
0

XAML , /, Assets .

<ResourceDictionary 
     Source="/MyAssemblyName;component/Assets/RadResources.xaml" />

.XAML Page .

0
source

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


All Articles