Home Forums WPF controls Other WPF controls How to apply Metro Ligth Theme to StyleableWindow using xaml

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • lonewolf000
    Participant
    Post count: 1
    #45023 |

    H. I’m new to using xceed components. i’d like to apply the metro light theme to my app but it was not being applied on my styleable window.

    here is what i did:

    in my app.xaml,

    <ResourceDictionary>
    <vm:ViewModelLocator x:Key=”Locator” d:IsDataSource=”True” />
    <DataTemplate DataType=”{x:Type vm:MainViewModel}”>
    <vw:initial />
    </DataTemplate>
    <ResourceDictionary.MergedDictionaries>
    <xcd:MetroLightThemeResourceDictionary LicenseKey=”xxxxxxxx”></xcd:MetroLightThemeResourceDictionary>
    <xcd:AllControlsResourceDictionary/>
    <xctt:ToolkitMetroDarkThemeResourceDictionary/>
    </ResourceDictionary.MergedDictionaries>

    </ResourceDictionary>

    and in the window i want to theme:

    <xctk:StyleableWindow x:Class=”Web2Pdf.MainWindow”
    xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”
    xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”
    xmlns:d=”http://schemas.microsoft.com/expression/blend/2008″
    xmlns:mc=”http://schemas.openxmlformats.org/markup-compatibility/2006″
    xmlns:local=”clr-namespace:Web2Pdf”
    xmlns:view=”clr-namespace:Web2Pdf.View”
    mc:Ignorable=”d”
    xmlns:xctk=”http://schemas.xceed.com/wpf/xaml/toolkit”
    xmlns:xcpt=”http://schemas.xceed.com/wpf/xaml/themes”
    xmlns:xctt=”http://schemas.xceed.com/wpf/xaml/toolkit/themes”
    Icon=”gnome_mime_application_pdf.ico”
    Title=”Web2Pdf” Height=”250″ Width=”400″>

    <view:initial />
    </xctk:StyleableWindow>

    i’ve been losing sleep for three nights because. of this. if anyone could help me it would be greatly appreciated.

    Diane [Xceed]
    Moderator
    Post count: 1353

    Hi,

    Try setting the style of the StyleableWindow based on the default StyleableWindow. Here’s an example:

    <Application x:Class="WpfApplication199.App"
                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:local="clr-namespace:WpfApplication199"
                xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
                xmlns:xcpt="http://schemas.xceed.com/wpf/xaml/themes"
                xmlns:xctt="http://schemas.xceed.com/wpf/xaml/toolkit/themes"
                StartupUri="MainWindow.xaml">
      <Application.Resources>
        <ResourceDictionary>
          <ResourceDictionary.MergedDictionaries>
            <xcpt:MetroLightThemeResourceDictionary AccentColor="Green" />
            <xctt:ToolkitMetroLightThemeResourceDictionary AccentColor="Green"
                                                          LicenseKey="XXXXX-XXXXX-XXXXX-XXXX"/>
          </ResourceDictionary.MergedDictionaries>
    
        </ResourceDictionary>
      </Application.Resources>
    </Application>
    <xctk:StyleableWindow x:Class="WpfApplication199.MainWindow"
                          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                          xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                          xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                          xmlns:local="clr-namespace:WpfApplication199"
                          xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
                          mc:Ignorable="d"
                          Title="MainWindow"
                          Height="350"
                          Width="525"
                          Style="{StaticResource {x:Type xctk:StyleableWindow}}">
      <StackPanel>
        <Button Content="TEST"
                Margin="20"
                Click="Button_Click"/>
        <xctk:DoubleUpDown Value="38"
                          Margin="20" />
      </StackPanel>
    </xctk:StyleableWindow>

    Usually, only setting the content of App.xaml is enough so that when you will create any Toolkit control, it will have the correct look. You can try it by popping a new StyleableWindow (or any other control) when clicking on a button. But for the main Window, you need to set the style so it applies at startup.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.