TechNinjutsu‎ > ‎

Adding Elysium for Windows 8/WP7 style in Win 7 using WPF with C#

posted Sep 26, 2012, 7:27 AM by d graham   [ updated Jul 1, 2013, 5:32 PM ]
Elysium is a 'Windows 8 style', open source, theme component released under the MIT license which is both free as in beer/soda and free as in speech.  I have decided to include Elysium in CdmaDevTerm(an open source project I develop).

Elysium provides two Windows 8 style themes which come in "Light" and "Dark"

Light:


 and Dark:


http://elysium.codeplex.com/ - is where the project hosting is, it is also available via nuGet now though.

In order to add Elysium to your project, grab the handful of .dll files which come with the example project which is provided by the authors and add them to your project:

Elysium.Theme.dll
Microsoft.Expression.Drawing.dll
Microsoft.Expression.Interactions.dll
Microsoft.Windows.Shell.dll
System.Windows.Interactivity.dll

Then on your xamal file add the name space bellow to the Window and preface the Window tag with the new namespace (metro:Window) :
xmlns:metro="http://schemas.codeplex.com/elysium/theme"

You will also have to change the class the main window inherits from in the code-behind file:
public partial class MainWindow : Elysium.Theme.Controls.Window

Then the last trick is in the main App.xamal you are going to want to add something like this:
<Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Elysium.Theme;component/Themes/Generic.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <!--Bug in .Net 4: http://connect.microsoft.com/VisualStudio/feedback/details/555322/global-wpf-styles-are-not-shown-when-using-2-levels-of-references-->
            <Style TargetType="{x:Type Window}"/>
        </ResourceDictionary>
    </Application.Resources>

The theme may be changed by calling for example:

Elysium.Theme.ThemeManager.Instance.Dark(Elysium.Theme.AccentColors.Lime);

which accepts as a parameter your choice of accent color.

Comments