Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Auto apply application-level resource-dictionary theme to all controls in program?

Auto apply application-level resource-dictionary theme to all controls in program?

Scheduled Pinned Locked Moved WPF
wpfcomquestionlearning
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    FocusedWolf
    wrote on last edited by
    #1

    So lets say i have some theme dll called: "ThemeAssortment.dll". And in a test-program i reference that dll and in my App.xaml" i do: <Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="ExpressionTheme.App" StartupUri="MainWindow.xaml"> <Application.Resources> <!-- Resources scoped at the Application level should be defined here. --> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/ThemeAssortment;Component/ColoredTheme.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources> </Application> So what do i need to do for this alone to auto-apply some styles to all controls in use in the application? If i do: <ScrollBar Style="{DynamicResource ScrollBar}" /> Then a scrollbar gets the appropriate scrollbar theme... but if i don't specify a Style... then one does not get automatically applied...

    P 1 Reply Last reply
    0
    • F FocusedWolf

      So lets say i have some theme dll called: "ThemeAssortment.dll". And in a test-program i reference that dll and in my App.xaml" i do: <Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="ExpressionTheme.App" StartupUri="MainWindow.xaml"> <Application.Resources> <!-- Resources scoped at the Application level should be defined here. --> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/ThemeAssortment;Component/ColoredTheme.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources> </Application> So what do i need to do for this alone to auto-apply some styles to all controls in use in the application? If i do: <ScrollBar Style="{DynamicResource ScrollBar}" /> Then a scrollbar gets the appropriate scrollbar theme... but if i don't specify a Style... then one does not get automatically applied...

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      This is down to how you define a style - if you define the target type instead of the key, it will get applied. For instance:

      <Style TargetType="ScrollBar">
      <Setter Property="MinWidth" Value="17"/>
      </Style>

      The key thing here is that no key has been added to the definition of the style.

      "WPF has many lovers. It's a veritable porn star!" - Josh Smith

      As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

      My blog | My articles | MoXAML PowerToys | Onyx

      F 1 Reply Last reply
      0
      • P Pete OHanlon

        This is down to how you define a style - if you define the target type instead of the key, it will get applied. For instance:

        <Style TargetType="ScrollBar">
        <Setter Property="MinWidth" Value="17"/>
        </Style>

        The key thing here is that no key has been added to the definition of the style.

        "WPF has many lovers. It's a veritable porn star!" - Josh Smith

        As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

        My blog | My articles | MoXAML PowerToys | Onyx

        F Offline
        F Offline
        FocusedWolf
        wrote on last edited by
        #3

        Thank you that worked perfectly :P

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups