SlideShare a Scribd company logo
Lesson 06 Styles and Templates in WPF
 Styling and templating refer
 Styles
 Templates
 Triggers
 Storyboards
 Allow create a consistent appearance
 Sharing the appearance within and among
applications
 Separation of presentation and logic
 Style is a set of properties to be applied to
more than one element
 Styles inWPF is similar to Cascading Styles
Sheets (CSS) from web development
 Styles enable developers and designers to
standardize on a particular appearance for
their product
 A maintainable code base
 Removed the redundancy
 Change the appearance of a set of controls
from a single point
 Possibility to swap the styles at runtime.
 Style can be extended base on another style
 A style inWPF can base on another style.
Without Styles
With Styles
The Result
 With a template you can replace parts inside
a user interface element..
 Advantages:
 Change the parts inside a user interface element
 Reduce the numbers custom controls
 ControlTemplates
 DataTemplates
 ControlTemplate of a control defines the
visual appearance of the control
 ControlTemplate makes change the structure
of a control or to set property values on the
components that comprise a control
 Each control has a default template
 Using Template dependency property to
replace default appearance of the control
Lesson 06 Styles and Templates in WPF
 A trigger sets properties or starts actions,
such as an animation, when a property value
changes or when an event is raised.
 Trigger are available on
 Style
 ControlTemplate
 DataTemplate
 ATrigger that sets property values or starts
actions based on the value of a property is
called a property trigger.
 EventTrigger,
which starts a
set of actions
based on the
occurrence of an
event.
 DataTemplates specify the appearance of a
control's content
 DataTemplates are frequently used to
enhance how bound data is displayed
 DataTemplates replace the visual appearance
of a data item in a control (ListBox,
ComboBox or ListView)
Without DataTemplates With DataTemplates
Named Definition
Inline Definition
Lesson 06 Styles and Templates in WPF
 WPF packaging user interface (UI) resources
as a theme by using a resource dictionary

More Related Content

What's hot (20)

PPTX
ASP.NET MVC Controllers & Actions
onsela
 
PPTX
MS Sql Server:Reporting models
DataminingTools Inc
 
PPTX
Attached property
msarangam
 
PDF
Data Binding and Data Grid View Classes
Arvind Krishnaa
 
PPTX
Android Training (Content Provider)
Khaled Anaqwa
 
PPTX
Ado.net
qamar mustafa
 
PPTX
Datasource in asp.net
Sireesh K
 
PPTX
Configuring Data Binding part2 ABTO Software Lecture Korotchyn
ABTO Software
 
PPTX
asp.net data controls
subakrish
 
PDF
WPF DATA BINDING CHEATSHEET V1.1
Vikas Pandey
 
PPTX
Configuring Data Binding part1 ABTO Software Lecture Korotchyn
ABTO Software
 
PPTX
Salesforce talk
Suvendu Roy
 
PPTX
SAP BO Web Intelligence Basics
Kiran Joy
 
PPTX
Binding radgridview into reportviewer
Junifar hidayat
 
PPTX
Android content provider explained
Shady Selim
 
PDF
Data Binding in Silverlight
Boulos Dib
 
PPT
Group Meeting Vamsas Project Final
Pierre Marguerite
 
PPTX
Grid Vew Control VB
sunmitraeducation
 
ASP.NET MVC Controllers & Actions
onsela
 
MS Sql Server:Reporting models
DataminingTools Inc
 
Attached property
msarangam
 
Data Binding and Data Grid View Classes
Arvind Krishnaa
 
Android Training (Content Provider)
Khaled Anaqwa
 
Ado.net
qamar mustafa
 
Datasource in asp.net
Sireesh K
 
Configuring Data Binding part2 ABTO Software Lecture Korotchyn
ABTO Software
 
asp.net data controls
subakrish
 
WPF DATA BINDING CHEATSHEET V1.1
Vikas Pandey
 
Configuring Data Binding part1 ABTO Software Lecture Korotchyn
ABTO Software
 
Salesforce talk
Suvendu Roy
 
SAP BO Web Intelligence Basics
Kiran Joy
 
Binding radgridview into reportviewer
Junifar hidayat
 
Android content provider explained
Shady Selim
 
Data Binding in Silverlight
Boulos Dib
 
Group Meeting Vamsas Project Final
Pierre Marguerite
 
Grid Vew Control VB
sunmitraeducation
 

Similar to Lesson 06 Styles and Templates in WPF (20)

PPT
WPF Line of Business Control Templates Styles
Our Community Exchange LLC
 
PPTX
Angular Directive.pptx
AshokKumar616995
 
PPTX
Directives.pptx
chauhanchauhan6354
 
PPTX
Silverlight control template
msarangam
 
PPTX
WPF with MVVM: From the Trenches
Brent Edwards
 
PPTX
Angular Components.pptx
AshokKumar616995
 
PPTX
Stephen Kennedy Silverlight 3 Deep Dive
MicrosoftFeed
 
PPTX
Technical stream presentation
Dynistics
 
PPTX
Simple mvc4 prepared by gigin krishnan
Gigin Krishnan
 
PPTX
Angular Framework ppt for beginners and advanced
Preetha Ganapathi
 
PPTX
J2EE pattern 5
Naga Muruga
 
PPT
17612235.ppt
yovixi5669
 
PPTX
Session 1
Asif Atick
 
PDF
.NET Core, ASP.NET Core Course, Session 11
Amin Mesbahi
 
PPT
MVC
akshin
 
PPTX
Angular Basics.pptx
AshokKumar616995
 
PPTX
MVC Training Part 2
Lee Englestone
 
PPTX
Angular 2
Pramod Raghav
 
PDF
Gof design pattern
naveen kumar
 
PPTX
Understanding angular js
Aayush Shrestha
 
WPF Line of Business Control Templates Styles
Our Community Exchange LLC
 
Angular Directive.pptx
AshokKumar616995
 
Directives.pptx
chauhanchauhan6354
 
Silverlight control template
msarangam
 
WPF with MVVM: From the Trenches
Brent Edwards
 
Angular Components.pptx
AshokKumar616995
 
Stephen Kennedy Silverlight 3 Deep Dive
MicrosoftFeed
 
Technical stream presentation
Dynistics
 
Simple mvc4 prepared by gigin krishnan
Gigin Krishnan
 
Angular Framework ppt for beginners and advanced
Preetha Ganapathi
 
J2EE pattern 5
Naga Muruga
 
17612235.ppt
yovixi5669
 
Session 1
Asif Atick
 
.NET Core, ASP.NET Core Course, Session 11
Amin Mesbahi
 
MVC
akshin
 
Angular Basics.pptx
AshokKumar616995
 
MVC Training Part 2
Lee Englestone
 
Angular 2
Pramod Raghav
 
Gof design pattern
naveen kumar
 
Understanding angular js
Aayush Shrestha
 
Ad

More from Quang Nguyễn Bá (19)

PPTX
Lesson 08 Documents and Printings in WPF
Quang Nguyễn Bá
 
PPTX
Lesson 07 Actions and Commands in WPF
Quang Nguyễn Bá
 
PPTX
Lesson 04 WPF Controls
Quang Nguyễn Bá
 
PPTX
Lesson 03 Layouts in WPF
Quang Nguyễn Bá
 
PPTX
Lesson 02 Introduction to XAML
Quang Nguyễn Bá
 
PPTX
Lesson 01 Introduction to WPF
Quang Nguyễn Bá
 
PPTX
Business intelligence
Quang Nguyễn Bá
 
PPTX
TDD - Test Driven Dvelopment | Test First Design
Quang Nguyễn Bá
 
PPTX
Scrum sử dụng Team Foundation Server 2012
Quang Nguyễn Bá
 
PPTX
Introduction to Microsoft SQL Server 2008 R2 Integration Services
Quang Nguyễn Bá
 
PPTX
Introduction to Business Intelligence in Microsoft SQL Server 2008 R2
Quang Nguyễn Bá
 
PPTX
Introduction to Microsoft SQL Server 2008 R2 Analysis Service
Quang Nguyễn Bá
 
PPTX
Office 2010 Programming
Quang Nguyễn Bá
 
PPTX
Giới thiệu WCF
Quang Nguyễn Bá
 
PPTX
MOSS 2007 Overview
Quang Nguyễn Bá
 
PPTX
SharePoint Programming Basic
Quang Nguyễn Bá
 
PPTX
SharePoint 2010 Business Intelligence
Quang Nguyễn Bá
 
PPTX
Programming SharePoint 2010 with Visual Studio 2010
Quang Nguyễn Bá
 
PPTX
SharePoint Web part programming
Quang Nguyễn Bá
 
Lesson 08 Documents and Printings in WPF
Quang Nguyễn Bá
 
Lesson 07 Actions and Commands in WPF
Quang Nguyễn Bá
 
Lesson 04 WPF Controls
Quang Nguyễn Bá
 
Lesson 03 Layouts in WPF
Quang Nguyễn Bá
 
Lesson 02 Introduction to XAML
Quang Nguyễn Bá
 
Lesson 01 Introduction to WPF
Quang Nguyễn Bá
 
Business intelligence
Quang Nguyễn Bá
 
TDD - Test Driven Dvelopment | Test First Design
Quang Nguyễn Bá
 
Scrum sử dụng Team Foundation Server 2012
Quang Nguyễn Bá
 
Introduction to Microsoft SQL Server 2008 R2 Integration Services
Quang Nguyễn Bá
 
Introduction to Business Intelligence in Microsoft SQL Server 2008 R2
Quang Nguyễn Bá
 
Introduction to Microsoft SQL Server 2008 R2 Analysis Service
Quang Nguyễn Bá
 
Office 2010 Programming
Quang Nguyễn Bá
 
Giới thiệu WCF
Quang Nguyễn Bá
 
MOSS 2007 Overview
Quang Nguyễn Bá
 
SharePoint Programming Basic
Quang Nguyễn Bá
 
SharePoint 2010 Business Intelligence
Quang Nguyễn Bá
 
Programming SharePoint 2010 with Visual Studio 2010
Quang Nguyễn Bá
 
SharePoint Web part programming
Quang Nguyễn Bá
 
Ad

Recently uploaded (20)

PPTX
Feb 2021 Cohesity first pitch presentation.pptx
enginsayin1
 
PDF
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
PPTX
An Introduction to ZAP by Checkmarx - Official Version
Simon Bennetts
 
PDF
Executive Business Intelligence Dashboards
vandeslie24
 
PPTX
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
PPTX
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
PDF
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
PPTX
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
PPTX
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
PDF
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PDF
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PDF
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
PPTX
Engineering the Java Web Application (MVC)
abhishekoza1981
 
DOCX
Import Data Form Excel to Tally Services
Tally xperts
 
PDF
Capcut Pro Crack For PC Latest Version {Fully Unlocked} 2025
hashhshs786
 
PDF
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
PPTX
MailsDaddy Outlook OST to PST converter.pptx
abhishekdutt366
 
Feb 2021 Cohesity first pitch presentation.pptx
enginsayin1
 
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
An Introduction to ZAP by Checkmarx - Official Version
Simon Bennetts
 
Executive Business Intelligence Dashboards
vandeslie24
 
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
Engineering the Java Web Application (MVC)
abhishekoza1981
 
Import Data Form Excel to Tally Services
Tally xperts
 
Capcut Pro Crack For PC Latest Version {Fully Unlocked} 2025
hashhshs786
 
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
MailsDaddy Outlook OST to PST converter.pptx
abhishekdutt366
 

Lesson 06 Styles and Templates in WPF

  • 2.  Styling and templating refer  Styles  Templates  Triggers  Storyboards  Allow create a consistent appearance  Sharing the appearance within and among applications  Separation of presentation and logic
  • 3.  Style is a set of properties to be applied to more than one element  Styles inWPF is similar to Cascading Styles Sheets (CSS) from web development  Styles enable developers and designers to standardize on a particular appearance for their product
  • 4.  A maintainable code base  Removed the redundancy  Change the appearance of a set of controls from a single point  Possibility to swap the styles at runtime.  Style can be extended base on another style
  • 5.  A style inWPF can base on another style.
  • 7.  With a template you can replace parts inside a user interface element..  Advantages:  Change the parts inside a user interface element  Reduce the numbers custom controls
  • 9.  ControlTemplate of a control defines the visual appearance of the control  ControlTemplate makes change the structure of a control or to set property values on the components that comprise a control  Each control has a default template  Using Template dependency property to replace default appearance of the control
  • 11.  A trigger sets properties or starts actions, such as an animation, when a property value changes or when an event is raised.  Trigger are available on  Style  ControlTemplate  DataTemplate
  • 12.  ATrigger that sets property values or starts actions based on the value of a property is called a property trigger.
  • 13.  EventTrigger, which starts a set of actions based on the occurrence of an event.
  • 14.  DataTemplates specify the appearance of a control's content  DataTemplates are frequently used to enhance how bound data is displayed  DataTemplates replace the visual appearance of a data item in a control (ListBox, ComboBox or ListView)
  • 15. Without DataTemplates With DataTemplates
  • 18.  WPF packaging user interface (UI) resources as a theme by using a resource dictionary

Editor's Notes

  • #8: An element like a button consists of multpiple composed parts: A border, a chrome and a content presenter. With styles you can only change the appearance from "outside" by setting public properties.
  • #10: For most controls, there is appearance and behavior. Consider a button: appearance is the raised area that you can press, and the behavior is the Click event that gets raised in response to a click. Sometimes, there may be a control that provides the behavior that you need but not the appearance that you need. So far, we have shown that you can use style setters to set property values to affect the look of control. However, to change the structure of a control or to set property values on the components that comprise a control, you need to use a ControlTemplate. Each control has a default template. This gives the control a basic appearance. The default template is typically shipped together with the control and available for all common windows themes. It is by convention wrapped into a style, that is identified by value of the DefaultStyleKey property that every control has.