WPF presets include Aero, Classic, Luna, and Royal themes. The WPF program determines the control style used by the WPF program based on the Windows theme, and when the Windows theme is not Aero, Luna, or Royal, if it is another topic, WPF will adopt an ugly Classic topic. How can I make the WPF program use the specified topic?
The following example shows how to set the topic as Aero:
Add the reference PresentationFramework. Aero. dll to the WPF project and add it to the Resources of the program. <Application. Resources>
<ResourceDictionary Source = "/PresentationFramework. Aero, Version = 3.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35; component/themes/aero. normalcolor. xaml"/>
</Application. Resources>
This is equivalent to referencing the spatial style code in the PresentationFramework. Aero assembly to the current program.
Note: The project must reference the Assembly corresponding to the topic, such as PresentationFramework. aero. dll, PresentationFramework. royale. dll and so on. They can be found in "Program Files \ Reference Assemblies \ Microsoft \ Framework \ v3.0" or GAC.
The above XAML code can also be replaced by the corresponding C # code, such as adding code to the Startup event handler of the Application: Protected override void OnStartup (StartupEventArgs e)
{
Base. OnStartup (e );
Uri aero = new Uri ("/PresentationFramework. Aero, Version = 3.0.0.0, Culture = neutral, PublicKeyToken = token; component/themes/aero. normalcolor. xaml", UriKind. Relative );
Resources. MergedDictionaries. Add (Application. LoadComponent (aero) as ResourceDictionary );
}
Of course, you can also add this ResourceDictionary to the Resources of the Window, so that this topic will only be used in this Window.
The method to specify other topics is similar, that is, reference related dll and add Resources.
The Aero themes in WPF are exactly the same style as those in Windows Vista, including the animation effects when MouseEnter is used, the following is an Aero-themed WPF program running on Windows 2003 with Luna Element 4 enabled:
However, the Aero topic in WPF does not have glass effect in non-Windows Vista systems. It is not something that GDI can do ..