I have reports.xaml page where I have defined some local resources.
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries >
<ResourceDictionary Source="/My.Namespace;component/Resources/Converters.xaml" />
<ResourceDictionary Source="/My.Namespace;component/Resources/GlobResources.xaml" />
<ResourceDictionary Source="/My.Namespace;component/Resources/ReportingResources.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
In the same reports.xaml file I have a content control like so...
<ContentControl
Content="{Binding}"
ContentTemplate="{Binding Converter={StaticResource reportTemplateSelector}, Path=CurrReportType}"
Margin="0"
/>
Now in my converter I load the ReportingResources.xaml resource file with the following lines of code
ResourceDictionary reportTemplate = new ResourceDictionary();
reportTemplate.Source = n开发者_如何学Pythonew Uri("/My.Namespace;component/Resources/ReportingResources.xaml", UriKind.Relative);
template = reportTemplate[Report_Style] as DataTemplate;
return template;
"Report_Style" will actually be a variable that will get set in Convert method of the reportTemplateSelector converter before the above lines get called.
The problem here is that ReportingResources.xaml is dependent on the GlobResources.xaml resource file for some other content. How do I make the content from GlobResources.xaml available to the ReportingResources.xaml file in the lines of code above?
Thanks for your time...
Have you tried....
A resource file can merge other resource files:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ResourceB.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style x:Name="MyButtonStyle" TargetType="Button">
<Setter Property="Background" Value="red"/>
</Style>
</ResourceDictionary>
Taken from Silverlight 3,0 Split styles and templates into different files and merge resources
精彩评论