Skip to content

Instantly share code, notes, and snippets.

@developerdizzle
Created March 7, 2012 04:52
Show Gist options
  • Save developerdizzle/1990997 to your computer and use it in GitHub Desktop.
Save developerdizzle/1990997 to your computer and use it in GitHub Desktop.
Base class for a WPF Window that automatically enables Aero/Glass effects (if available on Windows)
using System;
using Microsoft.WindowsAPICodePack.Shell;
namespace System.Windows
{
public class AutomaticGlassWindow : GlassWindow
{
public AutomaticGlassWindow() {
this.AeroGlassCompositionChanged += new EventHandler<AeroGlassCompositionChangedEventArgs>(AutomaticGlassWindow_AeroGlassCompositionChanged);
}
void AutomaticGlassWindow_AeroGlassCompositionChanged(object sender, AeroGlassCompositionChangedEventArgs e)
{
this.UpdateGlass(e.GlassAvailable);
}
protected override void OnSourceInitialized(EventArgs e)
{
base.OnSourceInitialized(e);
this.UpdateGlass(GlassWindow.AeroGlassCompositionEnabled);
}
private void UpdateGlass(bool aeroEnabled)
{
if (aeroEnabled)
{
this.SetAeroGlassTransparency();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment