Change Theme in Avalon Dock

3.1k views Asked by At

I am using Xceed.Wpf.AvalonDock in my WPF application.

I want a feature on the start page of my application which gives users an option to change the theme of the application by a click of a button/link.

Any suggestions how to do this?

Currently, I am using following code in XAML to set the Aero theme:

<avalonDock:DockingManager.Theme>
    <avalonDock:AeroTheme/>
</avalonDock:DockingManager.Theme>
3

There are 3 answers

0
Andreas Reitberger On

You can set the theme fix like this:

<xcad:DockingManager Grid.Row="1" MaxHeight="425"
                           AllowMixedOrientation="True"
                           BorderBrush="Black"
                           BorderThickness="1"
                           >
            <xcad:DockingManager.Theme>
                <xcad:MetroTheme />
            </xcad:DockingManager.Theme>
 </xcad:DockingManager>
0
zaknotzach On

You should be able to do this with a binding like any other property:

<avalonDock:DockingManager Theme="{Binding ThemeProperty}">
...
</avalonDock:DockingManager>

And then in your code just make your button or whatever control you use change ThemeProperty

0
Naser Asadi On

You can add a combo box which contains theme names, also each item's Tag is filled with its associated theme name:

<ComboBox>
    <ComboBoxItem Content="Generic" />
    <ComboBoxItem Content="Aero">
        <ComboBoxItem.Tag>
             <xcad:AeroTheme />
        </ComboBoxItem.Tag>
    </ComboBoxItem>
    <ComboBoxItem Content="VS2010">
        <ComboBoxItem.Tag>
            <xcad:VS2010Theme />
        </ComboBoxItem.Tag>
    </ComboBoxItem>
    <ComboBoxItem Content="Metro">
        <ComboBoxItem.Tag>
            <xcad:MetroTheme />
        </ComboBoxItem.Tag>
    </ComboBoxItem>
</ComboBox>

Then these tag names in items are used for binding to the Theme property in DockingManager:

<xcad:DockingManager Theme="{Binding ElementName=_themeCombo, Path=selectedItem.Tag}">