locked
Define My Own Theme Resources

    Question

  • Again,

    Probably very simplistic but I still retain that computers do what I tell them, not what someone else up the food chain decreed I "should" tell them.

    I create an App and the color scheme is all wonky (for my tastes).  Every new page i create defaults to this be-damned "ThemeResource" moniker.  So how do I create my own.  I want to open the "ThemeResource" file and change the values.  Or at least create my own ThemeResource and define what those resources are.

    This "should" be possible but I cannot find a simple guide to how.

    Thanks

    Jaeden "Sifo Dyas" al'Raec Ruiner


    "Never Trust a computer. Your brain is smarter than any micro-chip."
    PS - Don't mark answers on other people's questions. There are such things as Vacations and Holidays which may reduce timely activity, and until the person asking the question can test your answer, it is not correct just because you think it is. Marking it correct for them often stops other people from even reading the question and possibly providing the real "correct" answer.

    Friday, April 3, 2015 3:27 PM

All replies

  • Here's a tutorial for Themed Resource Dictionaries:
    http://blogs.msdn.com/b/mspfe/archive/2014/01/14/xaml-styles-and-themed-resources-in-windows-8-1.aspx

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Friday, April 3, 2015 7:41 PM
    Moderator
  • Excellent.

    Very helpful, save for one minor detail.  In the App.xaml there is a RequestedTheme but it only allows for Light or Dark.  If I create a ResourceDictionary as follows:

        <ResourceDictionary.ThemeDictionaries>
            <ResourceDictionary x:Key="Custom">
            </ResourceDictionary>
        </ResourceDictionary.ThemeDictionaries>

    there appears to be no way to reference my "Custom" theme in the resource binding:

    {ThemeResource AppMyHighlightBrush}

    There is no notation to say I want to use my "custom theme resource" for that element.

    Must I always use "Default" as the resourcedictionary, or am I missing something.

    Thanks
    J"SD"a'RR


    "Never Trust a computer. Your brain is smarter than any micro-chip."
    PS - Don't mark answers on other people's questions. There are such things as Vacations and Holidays which may reduce timely activity, and until the person asking the question can test your answer, it is not correct just because you think it is. Marking it correct for them often stops other people from even reading the question and possibly providing the real "correct" answer.

    Monday, April 6, 2015 2:01 PM
  • You cannot define your own themes in that way.

    What is the goal here? Why do you want to set the RequestedTheme to Custom rather than just defining the theme colours?

    The RequestedTheme allows the app to select between the Light and the Dark defaults. To create your own theme colours you will need to override the theme resources provided for a given theme.

    In your app.xaml.cs file you can create a ThemeDictionary for the theme you want to override and then set your custom colours there. You'll also need to set the HighContrast theme to fall back to the default colours.

    See the Remarks in the ResourceDictionary.ThemeDictionaries property documentation for more details.

    Tuesday, April 7, 2015 12:30 AM
    Owner
  • Well,

    I guess I'm thinking more in terms of inheritance (which is not XML or XAML i know).  Id like to have everything work of the base theme, light or dark, but if I want to customize the colors in anyway I'd wouldn't want to have to declare them direct.  Like if the top border of all my pages I want a shade of light blue, i'd want to define "CustomHeaderBackColor" and thus have that set, instead of overriding a theme defined color that might be used else where and still desired. 

    I'm still leaning the model here for the Store App framework so the nuanced details are a bit of anathema to my more traditional programming style.

    I've read all the spec sheets for ThemeDictionaries but none of them seem to describe what i'm talking about.  It's either override 20 specific color identifiers or I list the colors in ever control directly.  I thought there should be some happy medium, but maybe there isn't.

    Thanks

    J"SD"a'RR


    "Never Trust a computer. Your brain is smarter than any micro-chip."
    PS - Don't mark answers on other people's questions. There are such things as Vacations and Holidays which may reduce timely activity, and until the person asking the question can test your answer, it is not correct just because you think it is. Marking it correct for them often stops other people from even reading the question and possibly providing the real "correct" answer.

    Tuesday, April 7, 2015 8:41 PM