BrandonAGr
BrandonAGr

Reputation: 6017

Detect Aero or Classic theme in WPF

I found questions on how to load a resource dictionary to apply a specific windows theme, such as this question, but I don't want to load the resource dictionary for aero if the windows theme is already set to aero, is it possible do something in code behind that can determine what the current windows theme is?

Upvotes: 1

Views: 731

Answers (1)

Dean Kuga
Dean Kuga

Reputation: 12119

You can try DwmIsCompositionEnabled function... it will work for currently active user only.

[DllImport("dwmapi.dll")]
public static extern IntPtr DwmIsCompositionEnabled(out bool pfEnabled);

bool aeroEnabled = false;

if (NativeMethods.DwmIsCompositionEnabled(out aeroEnabled) == IntPtr.Zero)
{
    //Some code here
}

Upvotes: 2

Related Questions