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

PPTX
Lesson 09 Resources and Settings in WPF
PPTX
Lesson 05 Data Binding in WPF
PPT
Dev308
PPT
SciVerse Application Integration Points
PPTX
Interface connection
PPT
PPTX
Data Binding for Xamarin Forms In-Depth
PPTX
Advance Webpage Devlopment .NET
Lesson 09 Resources and Settings in WPF
Lesson 05 Data Binding in WPF
Dev308
SciVerse Application Integration Points
Interface connection
Data Binding for Xamarin Forms In-Depth
Advance Webpage Devlopment .NET

What's hot (20)

PPTX
ASP.NET MVC Controllers & Actions
PPTX
MS Sql Server:Reporting models
PPTX
Attached property
PDF
Data Binding and Data Grid View Classes
PPTX
Android Training (Content Provider)
PPTX
Ado.net
PPTX
Datasource in asp.net
PPTX
Configuring Data Binding part2 ABTO Software Lecture Korotchyn
PPTX
asp.net data controls
PDF
WPF DATA BINDING CHEATSHEET V1.1
PPTX
Configuring Data Binding part1 ABTO Software Lecture Korotchyn
PPTX
Salesforce talk
PPTX
SAP BO Web Intelligence Basics
PPTX
Binding radgridview into reportviewer
PPTX
Android content provider explained
PDF
Data Binding in Silverlight
PPT
Group Meeting Vamsas Project Final
PPTX
Grid Vew Control VB
ASP.NET MVC Controllers & Actions
MS Sql Server:Reporting models
Attached property
Data Binding and Data Grid View Classes
Android Training (Content Provider)
Ado.net
Datasource in asp.net
Configuring Data Binding part2 ABTO Software Lecture Korotchyn
asp.net data controls
WPF DATA BINDING CHEATSHEET V1.1
Configuring Data Binding part1 ABTO Software Lecture Korotchyn
Salesforce talk
SAP BO Web Intelligence Basics
Binding radgridview into reportviewer
Android content provider explained
Data Binding in Silverlight
Group Meeting Vamsas Project Final
Grid Vew Control VB
Ad

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

PPT
WPF Line of Business Control Templates Styles
PPTX
WPF - An introduction
PPT
A Tour of Windows Presentation Foundation (WPF)
PPT
Introduction to XAML and WPF
PPT
Catching up on Rich Clients Part 1 of 2
PPTX
Windows presentation foundation (wpf) and infragistics
PPT
Introduction To Wpf Engines
PPT
MSDN Unleashed: WPF Demystified
PPTX
Building Windows Presentation Foundation (WPF) Application
PPTX
Building Windows Presentation Foundation (WPF) Application
PPTX
Introduction to XAML and its features
PPTX
Chpater1
PPTX
The Magic of WPF & MVVM
PPT
Presentation wpf
PPT
2 Day - WPF Training by Adil Mughal
PPTX
Lesson 01 Introduction to WPF
PDF
Complete WPF Overview Tutorial with Example - iFour Technolab
PPT
WPF Windows Presentation Foundation A detailed overview Version1.2
PPTX
Creating Rich, Dynamic User Interfaces with Silverlight 2
PPTX
Windows Presentation Foundation & XAML
WPF Line of Business Control Templates Styles
WPF - An introduction
A Tour of Windows Presentation Foundation (WPF)
Introduction to XAML and WPF
Catching up on Rich Clients Part 1 of 2
Windows presentation foundation (wpf) and infragistics
Introduction To Wpf Engines
MSDN Unleashed: WPF Demystified
Building Windows Presentation Foundation (WPF) Application
Building Windows Presentation Foundation (WPF) Application
Introduction to XAML and its features
Chpater1
The Magic of WPF & MVVM
Presentation wpf
2 Day - WPF Training by Adil Mughal
Lesson 01 Introduction to WPF
Complete WPF Overview Tutorial with Example - iFour Technolab
WPF Windows Presentation Foundation A detailed overview Version1.2
Creating Rich, Dynamic User Interfaces with Silverlight 2
Windows Presentation Foundation & XAML
Ad

More from Quang Nguyễn Bá (18)

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

Recently uploaded (20)

PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
Essential Infomation Tech presentation.pptx
PPTX
Odoo POS Development Services by CandidRoot Solutions
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
L1 - Introduction to python Backend.pptx
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
System and Network Administration Chapter 2
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Softaken Excel to vCard Converter Software.pdf
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
CHAPTER 2 - PM Management and IT Context
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Navsoft: AI-Powered Business Solutions & Custom Software Development
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Design an Analysis of Algorithms I-SECS-1021-03
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Which alternative to Crystal Reports is best for small or large businesses.pdf
Essential Infomation Tech presentation.pptx
Odoo POS Development Services by CandidRoot Solutions
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
L1 - Introduction to python Backend.pptx
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
System and Network Administration Chapter 2

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.