none
Question about Common/StandardStyles.xaml, ControlTemplates and System Resources in VS11 Beta

    Question

  • When I create a new C# MetroStyleApp with VS11 Beta (or Blend), the file Common/StandardStyles.xaml is created by default.  Where do we find the implicit Styles and ControlTemplates for all of the standard controls that are not defined in StandardStyles: CheckBox, RadioButton, ListView, ...?

    Where do we find the definitions for the System Brush Resources such as ApplicationPageBackgroundBrush, ControlBorderBrush, ...?

    It seems like none of the SDK Samples have been updated to use the Common/StandardStyles.xaml, is the preferred approach over the Generic.xam (or lightGeneric.xaml)l that was included in many of the C# samples?

    Thanks in advance.

    Friday, March 02, 2012 6:37 PM

Answers

  • Hi Jay,

    If you select an element (such as a CheckBox) in the designer and right click there will be an "Edit Template" item in the context menu.

    How best to lay out your styles will depend on your specific project, but the Common/StandardStyles.xaml approach will work well for many. While it's overkill for many of the small samples, none of the CP samples I looked at still use generic.xaml / lightgeneric.xaml.

    --Rob

    Saturday, March 03, 2012 1:15 AM
    Owner
  • Jay - the standardstyles.xaml are above and beyond base control styles (i.e., generic.xaml).  As an example, this ResourceDictionary includes styles/templates for things like AppBar buttons, something that doesn't exist as a control in the framework and wouldn't exist in generic.xaml.  You can, of course, edit any core style/template using the Edit Template feature in Blend and/or Visual Studio.

    Also LightGeneric.xaml isn't needed anymore.  If you want the light them, in your App.xaml add RequestedTheme="Light" in the <Application> node and you'll automatically get the light theme.

    Hope this helps!


    Tim Heuer | Program Manager, XAML | http://timheuer.com/blog | @timheuer

    (if my post has answered your question, please consider using the 'mark as answer' feature in the forums to help others)

    Saturday, March 03, 2012 5:05 AM
  • These values come from the operating system at runtime and are not defined anywhere. You can see usages of these in this sample: http://code.msdn.microsoft.com/windowsapps/Basic-Media-Playback-662f1a7d

    -mark
    Program Manager
    Microsoft
    This post is provided "as-is"

    Wednesday, April 04, 2012 6:30 PM

All replies

  • Hi Jay,

    If you select an element (such as a CheckBox) in the designer and right click there will be an "Edit Template" item in the context menu.

    How best to lay out your styles will depend on your specific project, but the Common/StandardStyles.xaml approach will work well for many. While it's overkill for many of the small samples, none of the CP samples I looked at still use generic.xaml / lightgeneric.xaml.

    --Rob

    Saturday, March 03, 2012 1:15 AM
    Owner
  • Jay - the standardstyles.xaml are above and beyond base control styles (i.e., generic.xaml).  As an example, this ResourceDictionary includes styles/templates for things like AppBar buttons, something that doesn't exist as a control in the framework and wouldn't exist in generic.xaml.  You can, of course, edit any core style/template using the Edit Template feature in Blend and/or Visual Studio.

    Also LightGeneric.xaml isn't needed anymore.  If you want the light them, in your App.xaml add RequestedTheme="Light" in the <Application> node and you'll automatically get the light theme.

    Hope this helps!


    Tim Heuer | Program Manager, XAML | http://timheuer.com/blog | @timheuer

    (if my post has answered your question, please consider using the 'mark as answer' feature in the forums to help others)

    Saturday, March 03, 2012 5:05 AM
  • What about the "core" SystemResources such as ApplicationPageBackgroundBrush, ControlBorderBrush that are used extensively in the StandardStyles.xaml as well as the core control templates that can be accessed with Blend. 

    Is there any documentation or other way to find the names and suggested usage for these?

    Tuesday, April 03, 2012 4:50 PM
  • Core "theme" resources are defined in the runtime in a ThemeResources.xaml file. A copy of this file is distributed by the SDK and development tools such as Blend or Visual Studio. You can find both ThemeResources.xaml and Generic.xaml on your computer by looking under C:\Program Files\windows kits\8.0\Include\winrt\xaml\design. Note you should replace "Program Files" with the "x86" version if you are on a 64bit os.

    Generic.xaml contains both the "theme" resources as well as the default control templates. Note that changing this file does not affect the runtime but the development tools do rely on these files so they should not be modified.

    -mark
    Program Manager
    Microsoft
    This post is provided "as-is"

    Wednesday, April 04, 2012 3:50 AM
  • Thanks, that's a big help.  One more question - these files refer to a number of System resources, such as these (below), where are these defined? 

          <SolidColorBrush x:Key="AppBarFillBrush" Color="{StaticResource SystemColorHighlightColor}" />
          <SolidColorBrush x:Key="AppBarItemBackgroundBrush" Color="{StaticResource SystemColorButtonFaceColor}" />
          <SolidColorBrush x:Key="AppBarItemDisabledForegroundBrush" Color="{StaticResource SystemColorGrayTextColor}" />
          <SolidColorBrush x:Key="AppBarItemForegroundBrush" Color="{StaticResource SystemColorButtonTextColor}" />
          <SolidColorBrush x:Key="AppBarItemHoverBackgroundBrush" Color="{StaticResource SystemColorHighlightColor}" />
          <SolidColorBrush x:Key="AppBarItemHoverForegroundBrush" Color="{StaticResource SystemColorHighlightTextColor}" />
          <SolidColorBrush x:Key="AppBarItemPressedForegroundBrush" Color="{StaticResource SystemColorButtonFaceColor}" />

    Wednesday, April 04, 2012 5:20 PM
  • These values come from the operating system at runtime and are not defined anywhere. You can see usages of these in this sample: http://code.msdn.microsoft.com/windowsapps/Basic-Media-Playback-662f1a7d

    -mark
    Program Manager
    Microsoft
    This post is provided "as-is"

    Wednesday, April 04, 2012 6:30 PM
  • Mark's sample link got changed since the OP. Correcting and resurrecting because this post gets hit a lot by searches for how to use ThemeDictionaries and where the system color resources and brush resources exist.

    See: http://code.msdn.microsoft.com/windowsapps/XAML-high-contrast-style-c0ce936f

    Particularly look @ the scenario2.xaml page, where an in-page template definition is directly referencing Color="" values that use the resource keys for system colors like SystemColorHighlightTextColor.

    Monday, December 03, 2012 8:10 PM