3

I notice that resources defined in generic.xaml cannot be simply resolved via

this.TryFindResource("someKey");

And that instead they can only be referenced in the following manner

this.TryFindResource(new ComponentResourceKey(typeof(SomeTypeInAssembly), "someKey"))

However, suppose I have a custom control in another assembly with a default Style in generic.xaml ...how come this works, from within my WPF application, without having to pass a ComponentResourceKey?

this.TryFindResource(typeof(CustomControl));

How does it know which generic.xaml to look for, especially if I have multiple themes\generic.xaml resource dictionaries in multiple referenced control libraries for example?

Is there anyway to obtain a collection of all theme dictionaries in all assemblies referenced in the application? (eg where you have multiple control libraries referenced by your application, each with their own generic.xaml)

Does WPF even know of the existence of all theme / generic.xaml dictionaries in the scope of the application at any point in time? I get the impression that theme dictionaries are only "discovered" by the current WPF application when you supply a ComponentResourceKey, which clues in WPF where to look (but then why does TryFindResource(typeof(CustomControl)) work?)

blue18hutthutt
  • 3,191
  • 5
  • 34
  • 57

0 Answers0