SlideShare a Scribd company logo
Windows 8.1 Themes
JIM O’NEIL
BLUEMETAL ARCHITECTS
HTTP://CODOCENT.COM
http://bit.ly/Win81Themes
http://bit.ly/Win81Themes
Agenda
RequestedTheme
Resources
Theme Dictionaries
Styles
Theme Generation
RequestedTheme (redux)
Dynamicizing Static Resources
Requested Theme
Application.Current.RequestedTheme
◦ Values
◦ Light
◦ Dark (default)
◦ High-contrast (Alt+Left Shift+PrntScn) setting overrides
◦ Can be set only at startup
◦ App.xaml
◦ In constructor code for the application
http://bit.ly/AppRequestedTheme
Yes, even in 8.1. 8.1 can detect
change to high contrast though.
Resources
Static Dynamic Theme
All XAML platforms WPF Windows 8.1 (Phone and Modern
App)
Assigned during loading Evaluated at runtime Static + reaction to theme
changes
{StaticResource MyBrush} {DynamicResource MyBrush} {ThemeResource MyBrush}
No forward references Forward references supported No forward references
http://bit.ly/ThemeResources
Reusable XAML elements
◦ Brushes
◦ Styles
◦ Converters
ThemeResource Dictionaries
Shipped in SDK for convenience, but files not used at runtime
◦ C:Program Files (x86)Windows Kits8.1Includewinrtxamldesign
Default (aka Dark)
Light
HighContrast
<?xml version="1.0" encoding="utf-8"?>
<ResourceDictionary
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
<SolidColorBrush x:Name="BlockFill"
Color="Red">
…
http://bit.ly/ResourceDictionary
Theme Dictionary Organization
Define distinct XAML files to store resource values by theme
Styles
Controls in XAML-based technologies are “lookless”
Styles get applied implicitly or explicitly
Each built-in control has an implicit style (stored, but not loaded from, generic.xaml)
http://bit.ly/AddingControls
Explicit Style
Theme-dependent brushes
Over 350 named brushes with dark, light, and system color (high contrast) mappings
Used in control style and template definitions
Each ends in “ThemeBrush”
http://bit.ly/ThemeResources
Theming and Styles
Implicit styles and templates for controls can be found:
◦ In generic.xaml in the SDK folder
◦ At the Windows Dev Center: http://bit.ly/AddingControls
Dev Center documentation includes cut-and-pasteable
◦ Dark theme brush definitions
◦ Light theme brush definitions
◦ Shared resources
◦ Default style definition
http://bit.ly/AddingControls
Theme Generation
Challenge: Each control has a palette of theme color resources for various states (selected,
pointer over, disabled, etc.) How do you create a consistent set of brush defintions around a
base theme color?
HAMMER.Pants… Hyper-Awesome, Malicious, Markup Enabled Reality.
An open source project/utility that generates a modified generic.xaml replacing all the
colored brushes with ones generated from an input base color.
http://bit.ly/HAMMERPants
RequestedTheme redux
Challenge: How do you handle elements that should appear the same regardless of application
theme – for example, controls on flyouts which are usually light-themed?
Option 1: Create an explicit “always light” theme
Option 2: Leverage FrameworkElement.ThemeResource
http://bit.ly/RequestedTheme
Dynamicizing Static Resources
Resources are programmatically accessible in the Application.Current.Resources
dictionary
There are some nuances:
◦ Modifying the color property of a brush will apply that change automatically
◦ Assigning a new brush instance will not be acknowledged until another element loads that resource
(e.g., navigate to a new page)
◦ Refreshing cached page class instances (NavigationCacheMode.Enabled) requires additional work
Thank you.
Jim O’Neil
BlueMetal Architects
jim.oneil@outlook.com
http://codocent.com
@jimoneil
http://bit.ly/Win81Themes
http://bit.ly/Win81Themes

More Related Content

Similar to Windows 8.1 Themes

Asp.Net 2.0 Presentation
Asp.Net 2.0 PresentationAsp.Net 2.0 Presentation
Asp.Net 2.0 Presentation
sasidhar
 
Web Tools for GemStone/S
Web Tools for GemStone/SWeb Tools for GemStone/S
Web Tools for GemStone/S
ESUG
 
CustomizingStyleSheetsForHTMLOutputs
CustomizingStyleSheetsForHTMLOutputsCustomizingStyleSheetsForHTMLOutputs
CustomizingStyleSheetsForHTMLOutputs
Suite Solutions
 
VS Saturday 2019 - Xamarin.Forms 4.x
VS Saturday 2019 - Xamarin.Forms 4.xVS Saturday 2019 - Xamarin.Forms 4.x
VS Saturday 2019 - Xamarin.Forms 4.x
Marco Bortolin
 
CrowdFusion: The Front-End Edition, Part I: Presentation Layer
CrowdFusion: The Front-End Edition, Part I: Presentation LayerCrowdFusion: The Front-End Edition, Part I: Presentation Layer
CrowdFusion: The Front-End Edition, Part I: Presentation Layer
graybill
 
skintutorial
skintutorialskintutorial
skintutorial
tutorialsruby
 
skintutorial
skintutorialskintutorial
skintutorial
tutorialsruby
 
Introduction to Software Build Technology
Introduction to Software Build TechnologyIntroduction to Software Build Technology
Introduction to Software Build Technology
Philip Johnson
 
Having Fun Building Web Applications (Day 2 slides)
Having Fun Building Web Applications (Day 2 slides)Having Fun Building Web Applications (Day 2 slides)
Having Fun Building Web Applications (Day 2 slides)
Clarence Ngoh
 
Facets of applied smw
Facets of applied smwFacets of applied smw
Facets of applied smw
Jesse Wang
 
Build a chatroom!
Build a chatroom!Build a chatroom!
Build a chatroom!
SheilaJimenezMorejon
 
Btb017 David
Btb017 DavidBtb017 David
Btb017 David
Rohit Ray
 
Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01
Tony Frame
 
Drupalcamp Atlanta 2010 Design-to-Theme
Drupalcamp Atlanta 2010 Design-to-ThemeDrupalcamp Atlanta 2010 Design-to-Theme
Drupalcamp Atlanta 2010 Design-to-Theme
Mediacurrent
 
Getting Started in Custom Programming for Talent Sourcing
Getting Started in Custom Programming for Talent SourcingGetting Started in Custom Programming for Talent Sourcing
Getting Started in Custom Programming for Talent Sourcing
Glenn Gutmacher
 
Html5 introduction
Html5 introductionHtml5 introduction
Html5 introduction
Karthik Nallajalla
 
Code generation
Code generationCode generation
Code generation
Rafael Chaves
 
Dive into HTML5
Dive into HTML5Dive into HTML5
Dive into HTML5
Karthik Nallajalla
 
.NET Recommended Resources
.NET Recommended Resources.NET Recommended Resources
.NET Recommended Resources
Greg Sohl
 
Getting started with titanium
Getting started with titaniumGetting started with titanium
Getting started with titanium
Naga Harish M
 

Similar to Windows 8.1 Themes (20)

Asp.Net 2.0 Presentation
Asp.Net 2.0 PresentationAsp.Net 2.0 Presentation
Asp.Net 2.0 Presentation
 
Web Tools for GemStone/S
Web Tools for GemStone/SWeb Tools for GemStone/S
Web Tools for GemStone/S
 
CustomizingStyleSheetsForHTMLOutputs
CustomizingStyleSheetsForHTMLOutputsCustomizingStyleSheetsForHTMLOutputs
CustomizingStyleSheetsForHTMLOutputs
 
VS Saturday 2019 - Xamarin.Forms 4.x
VS Saturday 2019 - Xamarin.Forms 4.xVS Saturday 2019 - Xamarin.Forms 4.x
VS Saturday 2019 - Xamarin.Forms 4.x
 
CrowdFusion: The Front-End Edition, Part I: Presentation Layer
CrowdFusion: The Front-End Edition, Part I: Presentation LayerCrowdFusion: The Front-End Edition, Part I: Presentation Layer
CrowdFusion: The Front-End Edition, Part I: Presentation Layer
 
skintutorial
skintutorialskintutorial
skintutorial
 
skintutorial
skintutorialskintutorial
skintutorial
 
Introduction to Software Build Technology
Introduction to Software Build TechnologyIntroduction to Software Build Technology
Introduction to Software Build Technology
 
Having Fun Building Web Applications (Day 2 slides)
Having Fun Building Web Applications (Day 2 slides)Having Fun Building Web Applications (Day 2 slides)
Having Fun Building Web Applications (Day 2 slides)
 
Facets of applied smw
Facets of applied smwFacets of applied smw
Facets of applied smw
 
Build a chatroom!
Build a chatroom!Build a chatroom!
Build a chatroom!
 
Btb017 David
Btb017 DavidBtb017 David
Btb017 David
 
Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01
 
Drupalcamp Atlanta 2010 Design-to-Theme
Drupalcamp Atlanta 2010 Design-to-ThemeDrupalcamp Atlanta 2010 Design-to-Theme
Drupalcamp Atlanta 2010 Design-to-Theme
 
Getting Started in Custom Programming for Talent Sourcing
Getting Started in Custom Programming for Talent SourcingGetting Started in Custom Programming for Talent Sourcing
Getting Started in Custom Programming for Talent Sourcing
 
Html5 introduction
Html5 introductionHtml5 introduction
Html5 introduction
 
Code generation
Code generationCode generation
Code generation
 
Dive into HTML5
Dive into HTML5Dive into HTML5
Dive into HTML5
 
.NET Recommended Resources
.NET Recommended Resources.NET Recommended Resources
.NET Recommended Resources
 
Getting started with titanium
Getting started with titaniumGetting started with titanium
Getting started with titanium
 

More from Jim O'Neil

Azure and DevOps: ARM & ARM
Azure and DevOps: ARM & ARMAzure and DevOps: ARM & ARM
Azure and DevOps: ARM & ARM
Jim O'Neil
 
Weka Health Vaccine Smart Fridge
Weka Health Vaccine Smart FridgeWeka Health Vaccine Smart Fridge
Weka Health Vaccine Smart Fridge
Jim O'Neil
 
Go Serverless with Azure Functions
Go Serverless with Azure FunctionsGo Serverless with Azure Functions
Go Serverless with Azure Functions
Jim O'Neil
 
Windows Azure Cloud Services
Windows Azure Cloud ServicesWindows Azure Cloud Services
Windows Azure Cloud Services
Jim O'Neil
 
Windows Azure Overview
Windows Azure OverviewWindows Azure Overview
Windows Azure Overview
Jim O'Neil
 
Windows 8 App and Game Development Landscape
Windows 8 App and Game Development LandscapeWindows 8 App and Game Development Landscape
Windows 8 App and Game Development Landscape
Jim O'Neil
 
MongoDB and Windows Azure
MongoDB and Windows AzureMongoDB and Windows Azure
MongoDB and Windows Azure
Jim O'Neil
 
Azure overview
Azure overviewAzure overview
Azure overview
Jim O'Neil
 
Hadoop in the Cloud
Hadoop in the CloudHadoop in the Cloud
Hadoop in the Cloud
Jim O'Neil
 
The PaaS Landscape
The PaaS LandscapeThe PaaS Landscape
The PaaS Landscape
Jim O'Neil
 
Sampling from the Cloud Smorgasbord
Sampling from the Cloud SmorgasbordSampling from the Cloud Smorgasbord
Sampling from the Cloud Smorgasbord
Jim O'Neil
 
Drupal and Microsoft
Drupal and MicrosoftDrupal and Microsoft
Drupal and Microsoft
Jim O'Neil
 

More from Jim O'Neil (12)

Azure and DevOps: ARM & ARM
Azure and DevOps: ARM & ARMAzure and DevOps: ARM & ARM
Azure and DevOps: ARM & ARM
 
Weka Health Vaccine Smart Fridge
Weka Health Vaccine Smart FridgeWeka Health Vaccine Smart Fridge
Weka Health Vaccine Smart Fridge
 
Go Serverless with Azure Functions
Go Serverless with Azure FunctionsGo Serverless with Azure Functions
Go Serverless with Azure Functions
 
Windows Azure Cloud Services
Windows Azure Cloud ServicesWindows Azure Cloud Services
Windows Azure Cloud Services
 
Windows Azure Overview
Windows Azure OverviewWindows Azure Overview
Windows Azure Overview
 
Windows 8 App and Game Development Landscape
Windows 8 App and Game Development LandscapeWindows 8 App and Game Development Landscape
Windows 8 App and Game Development Landscape
 
MongoDB and Windows Azure
MongoDB and Windows AzureMongoDB and Windows Azure
MongoDB and Windows Azure
 
Azure overview
Azure overviewAzure overview
Azure overview
 
Hadoop in the Cloud
Hadoop in the CloudHadoop in the Cloud
Hadoop in the Cloud
 
The PaaS Landscape
The PaaS LandscapeThe PaaS Landscape
The PaaS Landscape
 
Sampling from the Cloud Smorgasbord
Sampling from the Cloud SmorgasbordSampling from the Cloud Smorgasbord
Sampling from the Cloud Smorgasbord
 
Drupal and Microsoft
Drupal and MicrosoftDrupal and Microsoft
Drupal and Microsoft
 

Recently uploaded

Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
AstuteBusiness
 
Public CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptxPublic CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptx
marufrahmanstratejm
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
Postman
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
LucaBarbaro3
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
saastr
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
Intelisync
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
Antonios Katsarakis
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
Javier Junquera
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
Miro Wengner
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
Hiike
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Precisely
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Jeffrey Haguewood
 
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
alexjohnson7307
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 

Recently uploaded (20)

Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
 
Public CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptxPublic CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptx
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
 
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 

Windows 8.1 Themes

  • 1. Windows 8.1 Themes JIM O’NEIL BLUEMETAL ARCHITECTS HTTP://CODOCENT.COM http://bit.ly/Win81Themes http://bit.ly/Win81Themes
  • 3. Requested Theme Application.Current.RequestedTheme ◦ Values ◦ Light ◦ Dark (default) ◦ High-contrast (Alt+Left Shift+PrntScn) setting overrides ◦ Can be set only at startup ◦ App.xaml ◦ In constructor code for the application http://bit.ly/AppRequestedTheme Yes, even in 8.1. 8.1 can detect change to high contrast though.
  • 4. Resources Static Dynamic Theme All XAML platforms WPF Windows 8.1 (Phone and Modern App) Assigned during loading Evaluated at runtime Static + reaction to theme changes {StaticResource MyBrush} {DynamicResource MyBrush} {ThemeResource MyBrush} No forward references Forward references supported No forward references http://bit.ly/ThemeResources Reusable XAML elements ◦ Brushes ◦ Styles ◦ Converters
  • 5. ThemeResource Dictionaries Shipped in SDK for convenience, but files not used at runtime ◦ C:Program Files (x86)Windows Kits8.1Includewinrtxamldesign Default (aka Dark) Light HighContrast <?xml version="1.0" encoding="utf-8"?> <ResourceDictionary xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> <ResourceDictionary.ThemeDictionaries> <ResourceDictionary x:Key="Default"> <SolidColorBrush x:Name="BlockFill" Color="Red"> … http://bit.ly/ResourceDictionary
  • 6. Theme Dictionary Organization Define distinct XAML files to store resource values by theme
  • 7. Styles Controls in XAML-based technologies are “lookless” Styles get applied implicitly or explicitly Each built-in control has an implicit style (stored, but not loaded from, generic.xaml) http://bit.ly/AddingControls Explicit Style
  • 8. Theme-dependent brushes Over 350 named brushes with dark, light, and system color (high contrast) mappings Used in control style and template definitions Each ends in “ThemeBrush” http://bit.ly/ThemeResources
  • 9. Theming and Styles Implicit styles and templates for controls can be found: ◦ In generic.xaml in the SDK folder ◦ At the Windows Dev Center: http://bit.ly/AddingControls Dev Center documentation includes cut-and-pasteable ◦ Dark theme brush definitions ◦ Light theme brush definitions ◦ Shared resources ◦ Default style definition http://bit.ly/AddingControls
  • 10. Theme Generation Challenge: Each control has a palette of theme color resources for various states (selected, pointer over, disabled, etc.) How do you create a consistent set of brush defintions around a base theme color? HAMMER.Pants… Hyper-Awesome, Malicious, Markup Enabled Reality. An open source project/utility that generates a modified generic.xaml replacing all the colored brushes with ones generated from an input base color. http://bit.ly/HAMMERPants
  • 11. RequestedTheme redux Challenge: How do you handle elements that should appear the same regardless of application theme – for example, controls on flyouts which are usually light-themed? Option 1: Create an explicit “always light” theme Option 2: Leverage FrameworkElement.ThemeResource http://bit.ly/RequestedTheme
  • 12. Dynamicizing Static Resources Resources are programmatically accessible in the Application.Current.Resources dictionary There are some nuances: ◦ Modifying the color property of a brush will apply that change automatically ◦ Assigning a new brush instance will not be acknowledged until another element loads that resource (e.g., navigate to a new page) ◦ Refreshing cached page class instances (NavigationCacheMode.Enabled) requires additional work
  • 13. Thank you. Jim O’Neil BlueMetal Architects jim.oneil@outlook.com http://codocent.com @jimoneil http://bit.ly/Win81Themes http://bit.ly/Win81Themes