I learned that WPF has a theme (theme here refers to Aero.NormalColor.xaml
and so on, like a link).These themes are probably published in Github.
Regarding the topic, the reference article is old, so the situation may be different now, but I have a question.
Q1.What is the default theme for WPF?(What's on the link?)Or something else?Isn't it open source?)
Q2.Is it possible to find out which themes are currently applied by mechanical means for any WPF application?(For example, I would be happy if I could get the theme (.xaml file) used from .exe or .dll.Can I use dnSpy??)
The environment should be Windows 10, .NET Core 3.0, but you can add additional assumptions to answer.
Thank you for your cooperation.
c# .net wpf
I have found a way to achieve it, so I will report it as an answer.
A1.As a result of A2, the conclusion was Aero2.NormalColor.xaml
in this environment.
A2.Tried several methods
<Application.Resources>
<ResourceDictionarySource="/PresentationFramework.<ThemeAssembly>component/themes/<ThemeFile>.xaml"/>
</Application.Resources>
Assembly.Load
.PresentationFramework.Aero2.dll
was loaded in this environment and no other themed DLLs were loaded.UxThemeWrapper.GetThemeNameAndColor
).
settings
argument of this method, LocalAssembly
can retrieve information about the DLL that contains the XAML resource, the XAML file that you are trying to load with the BaseUri
property.Aero2.NormalColor.xaml
, LocalAssembly
was PresentationFramework.Aero2
, but BaseUri
was null
.This is probably because you are trying to load directly from Stream that corresponds to resources, not from Uri.name
appears to be able to retrieve information about the corresponding DLL from the resource name, instance MainAssembly
property.name
found themes/aero2.normalcolor.baml
.These studies only show the DLLs and XAMLs loaded, and I'm not sure how they are applied in the actual WPF Tree, but I've accomplished my original goal, so I've stopped.
As a technical interest, I would like to continue to seek answers on how to conduct the above research in a reflective manner (i.e., in code).
If anyone has any knowledge, please let me know.
© 2024 OneMinuteCode. All rights reserved.