Home Forums WPF controls Xceed Toolkit Plus for WPF Uniform themes

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • obiben
    Participant
    Post count: 28
    #43991 |

    Hi there,

    I’ve been trying to overhaul my themes, but have been hitting a few snags:

    • Is there a way, for a class library, to apply a theme to all windows? It’s really not productive to change the code in every window.
    • How would I go about styling the actual windows? My controls (buttons, text fields, datagrids) get styled correctly, but the windows’ status bar and background remains the same.
    • Is there a known problem with AvalonDock and the Metro Accent theme? It can’t seem to be recognized (eg VS2015’s autocomplete wont suggest it, but it suggests everything else, including Metro)
    • AvalonDock is throwing exceptions about licensing, even though I’ve got my license key for the toolkit in the application startup. Is there a separate license for AvalonDock themes?
    • There’s a media theme for the toolkit and datagrid, but not avalondock – is that on the roadmap?
    • Same with live explorer
    • Do you have a suggestion of a combination of themes for a darker theme (such as media or or metro dark) that would look nice across all components?

    Thanks!
    Benoit

    obiben
    Participant
    Post count: 28

    I’ve taken care of the licensing issues by:

    1. Deleting all packages installed manually
    2. Installing both the full datagrid and toolkit plus via Nuget
    3. Deleting the conflicting .dll file that contains the base datagrid for toolkit
    4. Copying the licensing code in the app constructor rather than OnStartup. OnStartup worked for Datagrid, but it doesn’t for toolkit, it would seem – at least not when you apply a theme to AvalonDock!

    I’m down to:

    • Any way to apply a default theme for everything, globally?
    • How to apply a theme to the window’s top bar and background
    • AvalonDock: still not able to set the theme to MetroAccent. No media, no LiveExplorer.
    • Open to alternate suggestions for a coherent dark theme!
    obiben
    Participant
    Post count: 28

    At the moment Office2007Black looks exactly the same as Silver, except for Background="{x:Static xcpt:Office2007BlackResources.ApplicationBackgroundBrush}", which is actually black.

    I’m getting the following error, which don’t prevent a successful build:

    The specified value cannot be assigned. The following type was expected: “Theme”.

    Which refers to:

    
              <xcdg:DataGridControl x:Name="_orderList"
                                    ItemsSource="{Binding Source={StaticResource OrdersView}}"
                                    AutoCreateColumns="True"
                                    NavigationBehavior="RowOnly">
                                        <xcdg:DataGridControl.Columns>
                                            <xcdg:Column FieldName="Symbol.Symbol" Title="Symbol"/>
                                            <xcdg:Column FieldName="Price" Title="Price"/>
                                            <xcdg:Column FieldName="Proximity" Title="Proximity"/>
                                            <xcdg:Column FieldName="Current" Title="Current"/>
                                            <xcdg:Column FieldName="Available" Title="Available"/>
                                            <xcdg:Column FieldName="Side" Title="Side"/>
                                            <xcdg:Column FieldName="FollowUp.Symbol.Symbol" Title="FollowUp"/>
                                            <xcdg:Column FieldName="FollowUp.Price" Title="FU Price"/>
                                            <xcdg:Column FieldName="FollowUp.Available" Title="Available"/>
                                        </xcdg:DataGridControl.Columns>
                                        <xcdg:DataGridControl.View>
                                            <xcdg:TableflowView ColumnStretchMode="Last">
                                                <xcdg:TableflowView.Theme>
                                                    <xcdg:Office2007BlackTheme/>
                                                </xcdg:TableflowView.Theme>
                                            </xcdg:TableflowView>
                                        </xcdg:DataGridControl.View>
                                    </xcdg:DataGridControl>
    

    This seems to be the offending line: <xcdg:Office2007BlackTheme/>

    EDIT: Error was caused by duplicate themes in toolkit and datagrid’s ThemePack. After resolving conflicts, Office2007Black is still Silver.

    Fawzi [Xceed]
    Member
    Post count: 722

    Hi,

    1) Apply theme to all windows

    If you want to theme all Windows, you can do it in App.xaml. Setting the styles here will affect all your application Windows :

    <Application x:Class=”WpfApplication7.App”
    xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation&#8221;
    xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml&#8221;
    xmlns:local=”clr-namespace:WpfApplication7″
    xmlns:themes=”clr-namespace:Xceed.Wpf.Themes.Metro;assembly=Xceed.Wpf.Themes.Metro”
    xmlns:classLibrary1=”clr-namespace:ClassLibrary1;assembly=ClassLibrary1″
    StartupUri=”MainWindow.xaml”>
    <Application.Resources>
    <ResourceDictionary>
    <ResourceDictionary.MergedDictionaries>
    <themes:MetroDarkThemeResourceDictionary LicenseKey=”XXXXX-XXXXX-XXXXX-XXXX”/>
    </ResourceDictionary.MergedDictionaries>

    <Style TargetType=”{x:Type classLibrary1:MyWindow1}”
    BasedOn=”{StaticResource {x:Type Window}}” />
    <Style TargetType=”{x:Type classLibrary1:MyWindow2}”
    BasedOn=”{StaticResource {x:Type Window}}” />
    </ResourceDictionary>
    </Application.Resources>
    </Application>

    Or you could try the suggestion from here : http://www.nickdarnell.com/wpf-adventures-in-theming-part-2/

    2) Style Window’s status Bar and Background

    You can change the Background of a Window this way :
    <Application x:Class=”WpfApplication7.App”
    xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation&#8221;
    xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml&#8221;
    xmlns:local=”clr-namespace:WpfApplication7″
    xmlns:classLibrary1=”clr-namespace:ClassLibrary1;assembly=ClassLibrary1″
    StartupUri=”MainWindow.xaml”>
    <Application.Resources>
    <ResourceDictionary>
    <Style TargetType=”{x:Type classLibrary1:MyWindow1}”
    BasedOn=”{StaticResource {x:Type Window}}”>
    <Setter Property=”Background”
    Value=”Green” />
    </Style>
    </ResourceDictionary>
    </Application.Resources>
    </Application>

    But you can’t change the status bar (title Bar) as reported here : http://stackoverflow.com/questions/9978444/how-can-i-style-the-border-and-title-bar-of-a-window-in-wpf.
    You will have to modify the default window template in the theme used.

    You can always try the StyleableWindow control from the Toolkit, it has a WindowBackground property(which affect the Title Bar).

    3) AvalonDock and the Metro Accent theme not recognized

    The Metro With Accent theme is different, it needs more data and is dynamically constructed. You can set it from code-behind :
    _dockingManager.Theme = new Xceed.Wpf.AvalonDock.Themes.MetroAccentTheme( new Xceed.Wpf.AvalonDock.Themes.MetroAccent.AvalonDockMetroDarkThemeResourceDictionary( Brushes.HotPink ) );
    case 166373 has been created to be able to set it in XAML this way :
    <xcad:DockingManager.Theme>
    <xcad:MetroAccentTheme>
    <xcad:MetroAccentTheme.ThemeResourceDictionary>
    <xcad:AvalonDockMetroDarkThemeResourceDictionary AccentBrush=”Cyan” />
    </xcad:MetroAccentTheme.ThemeResourceDictionary>
    </xcad:MetroAccentTheme>
    </xcad:DockingManager.Theme>
    It will be available in v3.2 Plus.

    4) AvalonDock LicenseKey exception

    The same LicenseKey can be used for the Toolkit and AvalonDock. If a theme is applied before the LicenseKey is read, the exception could happen. Make sure to set the LicenseKey in that case as you defined the theme :
    <Application.Resources>
    <ResourceDictionary>
    <ResourceDictionary.MergedDictionaries>
    <themes:MetroDarkThemeResourceDictionary LicenseKey=”XXXXX-XXXXX-XXXXX-XXXX”/>
    </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
    </Application.Resources>

    5) Media Theme

    The Toolkit contains the following section :
    -AvalonDock
    -DataGrid
    -ListBox
    -core control
    -Toolkit core

    All these sections include the following themes for all their controls :
    -Windows7
    -Windows8
    -Office2007 Black/Blue/Silver
    -Metro (With Accent)
    -Windows10

    In addition, some sections have more themes :
    -AvalonDock : Aero, Metro, VS2010
    -ListBox : LiveExplorer, MediaPlayer11

    If you are referring to MediaPlayer11, only the Listbox includes this theme. If you try the Xceed DataGrid for WPF (the Complete DataGrid from Xceed), you will have more theme (including MediaPlayer11) :
    -Xceed DataGrid for WPF : Aero, XP Blue/Olive/Silver, Royale, Classic, Zune, MediaPlayer11 and LiveExplorer

    There is no Media theme for the Toolkit core control or Toolkit’s DataGrid. A media theme for AvalonDock is not on the map for now.

    6) LiveExplorer Theme

    As said in 5), the LiveExplorer theme is only available in the ListBox or the Xceed DataGrid for WPF (not the Toolkit’s DataGrid). A LiveExplorer theme for other controls is not on the map for now.

    7) The Metro Dark with Accent theme is available for all Toolkit’s control. It’s the safest bet.

    obiben
    Participant
    Post count: 28

    Thanks for the detailed answers.

    Note for eager googlers landing here: Datagrid also seems to require code-behind initialization:

    
                dataGrid.View.Theme = new Xceed.Wpf.DataGrid.ThemePack.MetroTheme(new Xceed.Wpf.DataGrid.ThemePack.MetroDarkThemeResourceDictionary(Brushes.DeepSkyBlue));
    


    @Fawzi
    :

    • Is setting the datagrid theme to metro accent from XAML also slated for 3.2?
    • Can you confirm that Office2007Black is actually silver? I see no difference from Office2007Black to Office2007Silver except the background bush
    Diane [Xceed]
    Moderator
    Post count: 1353

    The following issue is fixed in the latest version:

    AvalonDock (v3.2 Plus)
    In AvalonDock, the MetroAccent theme can now be set from XAML.

    Download Link: http://forums.xceed.com/latest-xceed-toolkit-plus-for-wpf

    Code example:

    xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock"
     <Grid>
          <xcad:DockingManager>
             <xcad:DockingManager.Theme>
                <xcad:MetroAccentTheme>
                   <xcad:MetroAccentTheme.ThemeResourceDictionary>
                      <xcad:AvalonDockMetroDarkThemeResourceDictionary AccentBrush="DarkBlue" />
                   </xcad:MetroAccentTheme.ThemeResourceDictionary>
                </xcad:MetroAccentTheme>
             </xcad:DockingManager.Theme>
          </xcad:DockingManager>
     </Grid>
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.