SlideShare a Scribd company logo
Don Burnett UXMagic.com http://Blog.DonBurnett.com
 
Overview Controls Styles Templates Creating New Controls
 
Controls WPF Object Model Visual UIElement FrameworkElement Control Control Base Classes WPF Toolbox New Controls
WPF Object Model Control FrameworkElement UIElement Visual Decorator Panel Shape FrameworkContentElement ContentElement Visual3D Freezable Animatable DispatcherObject Dependency Object
Background The Visual object is a core WPF object, with a primary role of providing rendering support. User interface controls, such as Button and TextBox, use the Visual defined properties for persisting their rendering data. The Visual object provides support for the following:  Output display Transformations Clipping Hit testing Bounding box calculations Architecturally, the Visual object does not include support for other application development requirements or WPF features that are not immediately related to its rendering; conceptually Visual is similar to an HWND (handle) in Win32. Visual is provided as a public abstract class from which further classes can be derived. Visual class provides for building a tree of visual objects, each optionally containing drawing instructions and metadata about how to render those instructions (clipping, transformation, etc.). Visual is designed to be extremely lightweight and flexible, so most of the features have no public API exposure and rely heavily on protected callback functions. Visual is really the entry point to the WPF composition system. Visual is the point of connection between these two subsystems, the managed API and the unmanaged milcore.
Visual Provides: Support for rendering Hit testing Clipping Transformations Similar to the Win32 handle  concept (HWND) Control FrameworkElement UIElement Visual
UIElement Provides: Support for user input events Support for routed events Support for routed commands Support for animation system BeginAnimation Logic for sizing and positioning Measure Arrange DesiredSize Control FrameworkElement UIElement Visual
UIElement UIElement introduces User interaction with Eventing, Input Commands and Layout. The UIElement class also introduces interaction with the animation system, particularly with Dependency Properties. A UIElement has the following capabilities that are specifically defined by the UIElement class:  Can respond to user input (including control of where input is getting sent to via their handling of event routing, or routing of commands)  Can raise routed events that travel a route through the logical element tree  Supports some aspects of the animation system  Contains logic that is used to size and position possible child elements of a UIElement (when interpreted by a layout system)
FrameworkElement Provides: Rich property metadata Additional layout characteristics Styles Storyboards Triggers Control FrameworkElement UIElement Visual
Control Provides Support for control templates Dependency properties for  use in control templates Control FrameworkElement UIElement Visual
Control Base Classes ItemsControl ContentControl FrameworkElement Control
WPF Toolbox ButtonBase Button GridViewColumnHeader RepeatButton ToggleButton CheckBox RadioButton Panel Canvas DockPanel Grid TabPanel ToolBarOverflowPanel UniformGrid StackPanel VirtualizingPanel WrapPanel ItemsControl HeaderedItemsControl MenuItem ToolBar TreeViewItem GroupBox MenuBase ContextMenu Menu Selector ComboBox ListBox ListView MultiSelector TabControl StatusBar TreeView ContentControl Label ListBoxItem ComboBoxItem FrameworkElement TextBlock
Toolbox continued...  Decorator Adorner Decorator ButtonChrome ListboxChrome  Border  Viewbox InkPresenter  ClassicBorderDecorator  Primitives Popup  Thumb GridSplitter ResizeGrip  TickBar Track TextBoxBase TextBox Shape Ellipse Rectangle Line Path RangeBase ScrollBar ProgressBar Slider Control PasswordBox Separator
New Controls Released on CodePlex DataGrid Calendar/DatePicker In CTP Ribbon
 
Styles Styles in WPF Extending Styles Styles in XAML Applying Styles
Purpose The main purpose behind the concept of styles in WPF is to group together property values that could otherwise be set individually; after a style is set up the intention is to then share this group of values among multiple elements of a similar type. Without styles values would have to be duplicated on all the controls; styles therefore save time and are more maintainable and less error prone than setting many property values individually. Setting a property directly on the element supersedes any value specified in its style. The Setter Properties are grouped together into a single Style object. A collection of Style objects can exist in the Resources section of either a control or the XAML page.
A collection property values Grouped together by using the  <style>  element or  System.Windows.Style  type Styles are used to define a control template Styles can be named by using the x:Key attribute Styles In WPF =
Extending Styles Styles can be extended by using the BasedOn property to point to an existing Style All the setters of the base style are inherited by the new style Framework styles can be extended by using the BasedOn property in conjunction with the x:Key property
Extending Styles
Applying Styles Styles can be applied by  Name/Key (explicit) Type (implicit) Scope Styles can be applied by using a combination these methods An element uses a style if it is the right type and in scope, or by using the Style attribute
Applying Styles Scope
 
Templates Lookless Controls Templates in WPF Control Templates TemplateBinding
Lookless Controls Look defined separately from the implementation Defined in a theme file Defined by a designer Controls usually have a default  “style”  Change look without recompiling control source Support behaviors Have no built-in visual representation Enabled by ControlTemplates
Control Templates Templates define the structure for a control The visual tree that a template defines, expands for each instance of the control that uses the template
Templates In WPF =
Templates In WPF Define elements within the visual tree Replacing templates only changes the look, not the behaviour Every control that ships with WPF has a template Do not inherit by using the BasedOn property
TemplateBinding Binds the value of a property on an element in a control template to the value of a property on the templated control Prevents element values set on a child from being overwritten by the control template Uses the TemplateBinding markup extension
 
Creating New Controls WPF provides three control-authoring models for creating your own controls: Deriving from the UserControl class Deriving from the Control class Deriving from the FrameworkElement class
UserControls Creating a UserControl enables new controls to be created by adding composing exiting controls For example, building a search control by using a Textbox and Button UserControl is a ContentControl To create a UserControl Define a class that inherits from UserControl Define a XAML UserControl element and then compose the desired interface
Derived Control Derive from a control and change functionality or properties without changing the ControlTemplate UserControl derives from ContentControl, which  in turn is derived from Control. Deriving from UserControl gives the control access to rich content, styles and triggers for free and provides a suitable framework to build the new control using pre existing elements.
Custom Control Derive from a control or FrameworkElement class Selecting the correct base class is important Provide functionality and expose properties in code Provide ControlTemplate
References WPF on CodePlex http://wpf.codeplex.com/
 

More Related Content

What's hot (20)

PDF
Visual basic 6 black book
Ajay Goyal
 
PPT
Grasping The LightSwitch Paradigm
Andrew Brust
 
PDF
Visual Basic IDE Introduction
Ahllen Javier
 
PPTX
The ms visual basic 6
Eyelean xilef
 
PPTX
Advanced java lab swing mvc awt
vishal choudhary
 
PPTX
Visual basic
KavithaAlagumalai
 
PDF
Ma3696 Lecture 2
Brunel University
 
PPTX
Toolbar, statusbar, coolbar in vb
Amandeep Kaur
 
PPTX
Basic controls of Visual Basic 6.0
Salim M
 
PPT
Introduction to programming using Visual Basic 6
Jeanie Arnoco
 
PPT
Meaning Of VB
Mohit Verma
 
DOC
Forms personalization
Rajiv reddy
 
PDF
personalization
sanodia77
 
PPT
Vb unit t 1.1
Gayathri Cit
 
PPSX
Unit2
Abha Damani
 
PPTX
Visusual basic
Mandavi Classes
 
PPT
MVC
akshin
 
PPT
Addmi 09-analysis ui-reporting
odanyboy
 
DOCX
Creating a data report in visual basic 6
mrgulshansharma
 
DOCX
Visual C# 2010
Ali Mattash
 
Visual basic 6 black book
Ajay Goyal
 
Grasping The LightSwitch Paradigm
Andrew Brust
 
Visual Basic IDE Introduction
Ahllen Javier
 
The ms visual basic 6
Eyelean xilef
 
Advanced java lab swing mvc awt
vishal choudhary
 
Visual basic
KavithaAlagumalai
 
Ma3696 Lecture 2
Brunel University
 
Toolbar, statusbar, coolbar in vb
Amandeep Kaur
 
Basic controls of Visual Basic 6.0
Salim M
 
Introduction to programming using Visual Basic 6
Jeanie Arnoco
 
Meaning Of VB
Mohit Verma
 
Forms personalization
Rajiv reddy
 
personalization
sanodia77
 
Vb unit t 1.1
Gayathri Cit
 
Visusual basic
Mandavi Classes
 
MVC
akshin
 
Addmi 09-analysis ui-reporting
odanyboy
 
Creating a data report in visual basic 6
mrgulshansharma
 
Visual C# 2010
Ali Mattash
 

Viewers also liked (9)

PDF
.NET Difference Between Interview Questions - Compiled
Umar Ali
 
PDF
VB.NET Difference FAQs-1
Umar Ali
 
PDF
Collaborative, Context Based Activity Control Method for Camera Networks
Marek Kraft
 
PPTX
SWEET SHOP
Tania Ospina Toro
 
PDF
10 Ways to Boost Employee Morale
Jay Moneta
 
PPTX
Marketing new product launch ppt
bilal khan
 
PPT
Booster Juice
emillysorensen
 
PDF
Fruit punch - Launching a New Product - Marketing
Cotecna Inspection
 
PDF
business plan (smoothy juice)
A. F. M. Rubayat-Ul Jannat
 
.NET Difference Between Interview Questions - Compiled
Umar Ali
 
VB.NET Difference FAQs-1
Umar Ali
 
Collaborative, Context Based Activity Control Method for Camera Networks
Marek Kraft
 
SWEET SHOP
Tania Ospina Toro
 
10 Ways to Boost Employee Morale
Jay Moneta
 
Marketing new product launch ppt
bilal khan
 
Booster Juice
emillysorensen
 
Fruit punch - Launching a New Product - Marketing
Cotecna Inspection
 
business plan (smoothy juice)
A. F. M. Rubayat-Ul Jannat
 
Ad

Similar to WPF Line of Business Control Templates Styles (20)

PPTX
Lesson 06 Styles and Templates in WPF
Quang Nguyễn Bá
 
PPTX
New Introductionfor Flash Designers
Our Community Exchange LLC
 
PPT
WPF Windows Presentation Foundation A detailed overview Version1.2
Shahzad
 
PPT
Windows Forms 2.0 Enhancements
guestd115f
 
PPTX
Stephen Kennedy Silverlight 3 Deep Dive
MicrosoftFeed
 
PPT
Adobe Flex Introduction
Amal Biswas
 
DOC
Form part1
Sanjeev Pandey
 
PPT
Test
guest25229c
 
PDF
Oracle11g form-course-curriculum
Amit Sharma
 
PDF
Oracle11g form course-curriculum
Amit Sharma
 
PDF
Oracle fusion middleware 11g build applications with oracle forms
bispsolutions
 
PPT
2 Day - WPF Training by Adil Mughal
Adil Mughal
 
PPTX
ASP.MVC Training
Mahesh Sikakolli
 
PPTX
MVC Training Part 2
Lee Englestone
 
PPTX
Exploring Adobe Flex
senthil0809
 
PPTX
Model View Presenter (MVP) In Aspnet
rainynovember12
 
PPTX
Visual Basic.pptx
KavithaAlagumalai
 
PPTX
Introduction to ASP.NET MVC
Julia Vi
 
PDF
Ajp notes-chapter-01
Ankit Dubey
 
PPTX
Silverlight control template
msarangam
 
Lesson 06 Styles and Templates in WPF
Quang Nguyễn Bá
 
New Introductionfor Flash Designers
Our Community Exchange LLC
 
WPF Windows Presentation Foundation A detailed overview Version1.2
Shahzad
 
Windows Forms 2.0 Enhancements
guestd115f
 
Stephen Kennedy Silverlight 3 Deep Dive
MicrosoftFeed
 
Adobe Flex Introduction
Amal Biswas
 
Form part1
Sanjeev Pandey
 
Oracle11g form-course-curriculum
Amit Sharma
 
Oracle11g form course-curriculum
Amit Sharma
 
Oracle fusion middleware 11g build applications with oracle forms
bispsolutions
 
2 Day - WPF Training by Adil Mughal
Adil Mughal
 
ASP.MVC Training
Mahesh Sikakolli
 
MVC Training Part 2
Lee Englestone
 
Exploring Adobe Flex
senthil0809
 
Model View Presenter (MVP) In Aspnet
rainynovember12
 
Visual Basic.pptx
KavithaAlagumalai
 
Introduction to ASP.NET MVC
Julia Vi
 
Ajp notes-chapter-01
Ankit Dubey
 
Silverlight control template
msarangam
 
Ad

More from Our Community Exchange LLC (9)

PPTX
Real Time Connected Vehicle Networking with HDInsight and Apache Storm
Our Community Exchange LLC
 
PPTX
2012 Updated Portfolio
Our Community Exchange LLC
 
PPTX
Roi and user experience
Our Community Exchange LLC
 
PPTX
I phone versus windows phone 7 coding
Our Community Exchange LLC
 
PDF
U Xmagic Agile Presentation
Our Community Exchange LLC
 
PPT
Porting the Legacy Application to Composite Application Guidance
Our Community Exchange LLC
 
PPT
WPF Fundamentals
Our Community Exchange LLC
 
PPTX
WPF Line of Business Application XAML Layouts Presentation
Our Community Exchange LLC
 
PPTX
Wpf Tech Overview2009
Our Community Exchange LLC
 
Real Time Connected Vehicle Networking with HDInsight and Apache Storm
Our Community Exchange LLC
 
2012 Updated Portfolio
Our Community Exchange LLC
 
Roi and user experience
Our Community Exchange LLC
 
I phone versus windows phone 7 coding
Our Community Exchange LLC
 
U Xmagic Agile Presentation
Our Community Exchange LLC
 
Porting the Legacy Application to Composite Application Guidance
Our Community Exchange LLC
 
WPF Fundamentals
Our Community Exchange LLC
 
WPF Line of Business Application XAML Layouts Presentation
Our Community Exchange LLC
 
Wpf Tech Overview2009
Our Community Exchange LLC
 

Recently uploaded (20)

PDF
UGC.pdfnsgsjshshsbhsbsjsshisggzvshsggsihsgsush
Nitishsingh548979
 
PPTX
Exploring Fashion Design – Creativity, Culture &.pptx
shilakhadutta33257
 
PPTX
CHANDIGARH Architecture Design and Planning
FaizSaifi3
 
PDF
Transforming_Spaces_PresentatioTransforming Spaces: The Power of Interior Des...
Royal Matrixs
 
PDF
Top Python development services company in Bangalore
Zinavo Technologies
 
PPTX
Premium Slide's Formatting Services.pptx
Mahendra Kumar
 
PPTX
shreyansh design sardar Patel college.pptx
ParimalMakadi
 
PPT
APPLIED ASPECTS OF PUBERTY AND ADOLESCENCE (final)[1].ppt
divyaunkule1829
 
PPT
dejjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjsi.ppt
DenyatiSipayung
 
PPTX
presentation prsentation presentation presentation
ssun76691
 
PPTX
presentation prsentation presentation presentation
ssun76691
 
PPTX
Infoblox_deck_1111111DDI_sbe_201302.pptx
eyala75
 
PDF
Comic Strip .pdf present, past and future
monserrathatena
 
PPTX
4-slide-sinh-nhat ( Happy birthday to you 4 )
MichaelVo23
 
PDF
sách về ống nnnnnnnnnnnnnnnnnnnnnnnnnnnnn
nmc12345
 
PPTX
Book Club Plan plan planning planning good
AmartyaPathak
 
PDF
Acoustic Reflex Box Patternnvhjmmkkvcgjjmmi
kaurmuskanpreet2504
 
DOCX
EE3012 Electric DrivesCOURSE INFORMATION.docx
saranyaN63
 
PPTX
Can Tho Vietnam i love my countryyy.pptx
ThMai55
 
PDF
CXEO CONSTRUCTION EXECUTIVE ENTREPRENEUR OWNER ACADEMY - Brand book
impybla
 
UGC.pdfnsgsjshshsbhsbsjsshisggzvshsggsihsgsush
Nitishsingh548979
 
Exploring Fashion Design – Creativity, Culture &.pptx
shilakhadutta33257
 
CHANDIGARH Architecture Design and Planning
FaizSaifi3
 
Transforming_Spaces_PresentatioTransforming Spaces: The Power of Interior Des...
Royal Matrixs
 
Top Python development services company in Bangalore
Zinavo Technologies
 
Premium Slide's Formatting Services.pptx
Mahendra Kumar
 
shreyansh design sardar Patel college.pptx
ParimalMakadi
 
APPLIED ASPECTS OF PUBERTY AND ADOLESCENCE (final)[1].ppt
divyaunkule1829
 
dejjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjsi.ppt
DenyatiSipayung
 
presentation prsentation presentation presentation
ssun76691
 
presentation prsentation presentation presentation
ssun76691
 
Infoblox_deck_1111111DDI_sbe_201302.pptx
eyala75
 
Comic Strip .pdf present, past and future
monserrathatena
 
4-slide-sinh-nhat ( Happy birthday to you 4 )
MichaelVo23
 
sách về ống nnnnnnnnnnnnnnnnnnnnnnnnnnnnn
nmc12345
 
Book Club Plan plan planning planning good
AmartyaPathak
 
Acoustic Reflex Box Patternnvhjmmkkvcgjjmmi
kaurmuskanpreet2504
 
EE3012 Electric DrivesCOURSE INFORMATION.docx
saranyaN63
 
Can Tho Vietnam i love my countryyy.pptx
ThMai55
 
CXEO CONSTRUCTION EXECUTIVE ENTREPRENEUR OWNER ACADEMY - Brand book
impybla
 

WPF Line of Business Control Templates Styles

  • 1. Don Burnett UXMagic.com http://Blog.DonBurnett.com
  • 2.  
  • 3. Overview Controls Styles Templates Creating New Controls
  • 4.  
  • 5. Controls WPF Object Model Visual UIElement FrameworkElement Control Control Base Classes WPF Toolbox New Controls
  • 6. WPF Object Model Control FrameworkElement UIElement Visual Decorator Panel Shape FrameworkContentElement ContentElement Visual3D Freezable Animatable DispatcherObject Dependency Object
  • 7. Background The Visual object is a core WPF object, with a primary role of providing rendering support. User interface controls, such as Button and TextBox, use the Visual defined properties for persisting their rendering data. The Visual object provides support for the following: Output display Transformations Clipping Hit testing Bounding box calculations Architecturally, the Visual object does not include support for other application development requirements or WPF features that are not immediately related to its rendering; conceptually Visual is similar to an HWND (handle) in Win32. Visual is provided as a public abstract class from which further classes can be derived. Visual class provides for building a tree of visual objects, each optionally containing drawing instructions and metadata about how to render those instructions (clipping, transformation, etc.). Visual is designed to be extremely lightweight and flexible, so most of the features have no public API exposure and rely heavily on protected callback functions. Visual is really the entry point to the WPF composition system. Visual is the point of connection between these two subsystems, the managed API and the unmanaged milcore.
  • 8. Visual Provides: Support for rendering Hit testing Clipping Transformations Similar to the Win32 handle concept (HWND) Control FrameworkElement UIElement Visual
  • 9. UIElement Provides: Support for user input events Support for routed events Support for routed commands Support for animation system BeginAnimation Logic for sizing and positioning Measure Arrange DesiredSize Control FrameworkElement UIElement Visual
  • 10. UIElement UIElement introduces User interaction with Eventing, Input Commands and Layout. The UIElement class also introduces interaction with the animation system, particularly with Dependency Properties. A UIElement has the following capabilities that are specifically defined by the UIElement class: Can respond to user input (including control of where input is getting sent to via their handling of event routing, or routing of commands) Can raise routed events that travel a route through the logical element tree Supports some aspects of the animation system Contains logic that is used to size and position possible child elements of a UIElement (when interpreted by a layout system)
  • 11. FrameworkElement Provides: Rich property metadata Additional layout characteristics Styles Storyboards Triggers Control FrameworkElement UIElement Visual
  • 12. Control Provides Support for control templates Dependency properties for use in control templates Control FrameworkElement UIElement Visual
  • 13. Control Base Classes ItemsControl ContentControl FrameworkElement Control
  • 14. WPF Toolbox ButtonBase Button GridViewColumnHeader RepeatButton ToggleButton CheckBox RadioButton Panel Canvas DockPanel Grid TabPanel ToolBarOverflowPanel UniformGrid StackPanel VirtualizingPanel WrapPanel ItemsControl HeaderedItemsControl MenuItem ToolBar TreeViewItem GroupBox MenuBase ContextMenu Menu Selector ComboBox ListBox ListView MultiSelector TabControl StatusBar TreeView ContentControl Label ListBoxItem ComboBoxItem FrameworkElement TextBlock
  • 15. Toolbox continued... Decorator Adorner Decorator ButtonChrome ListboxChrome Border Viewbox InkPresenter ClassicBorderDecorator Primitives Popup Thumb GridSplitter ResizeGrip TickBar Track TextBoxBase TextBox Shape Ellipse Rectangle Line Path RangeBase ScrollBar ProgressBar Slider Control PasswordBox Separator
  • 16. New Controls Released on CodePlex DataGrid Calendar/DatePicker In CTP Ribbon
  • 17.  
  • 18. Styles Styles in WPF Extending Styles Styles in XAML Applying Styles
  • 19. Purpose The main purpose behind the concept of styles in WPF is to group together property values that could otherwise be set individually; after a style is set up the intention is to then share this group of values among multiple elements of a similar type. Without styles values would have to be duplicated on all the controls; styles therefore save time and are more maintainable and less error prone than setting many property values individually. Setting a property directly on the element supersedes any value specified in its style. The Setter Properties are grouped together into a single Style object. A collection of Style objects can exist in the Resources section of either a control or the XAML page.
  • 20. A collection property values Grouped together by using the <style> element or System.Windows.Style type Styles are used to define a control template Styles can be named by using the x:Key attribute Styles In WPF =
  • 21. Extending Styles Styles can be extended by using the BasedOn property to point to an existing Style All the setters of the base style are inherited by the new style Framework styles can be extended by using the BasedOn property in conjunction with the x:Key property
  • 23. Applying Styles Styles can be applied by Name/Key (explicit) Type (implicit) Scope Styles can be applied by using a combination these methods An element uses a style if it is the right type and in scope, or by using the Style attribute
  • 25.  
  • 26. Templates Lookless Controls Templates in WPF Control Templates TemplateBinding
  • 27. Lookless Controls Look defined separately from the implementation Defined in a theme file Defined by a designer Controls usually have a default “style” Change look without recompiling control source Support behaviors Have no built-in visual representation Enabled by ControlTemplates
  • 28. Control Templates Templates define the structure for a control The visual tree that a template defines, expands for each instance of the control that uses the template
  • 30. Templates In WPF Define elements within the visual tree Replacing templates only changes the look, not the behaviour Every control that ships with WPF has a template Do not inherit by using the BasedOn property
  • 31. TemplateBinding Binds the value of a property on an element in a control template to the value of a property on the templated control Prevents element values set on a child from being overwritten by the control template Uses the TemplateBinding markup extension
  • 32.  
  • 33. Creating New Controls WPF provides three control-authoring models for creating your own controls: Deriving from the UserControl class Deriving from the Control class Deriving from the FrameworkElement class
  • 34. UserControls Creating a UserControl enables new controls to be created by adding composing exiting controls For example, building a search control by using a Textbox and Button UserControl is a ContentControl To create a UserControl Define a class that inherits from UserControl Define a XAML UserControl element and then compose the desired interface
  • 35. Derived Control Derive from a control and change functionality or properties without changing the ControlTemplate UserControl derives from ContentControl, which in turn is derived from Control. Deriving from UserControl gives the control access to rich content, styles and triggers for free and provides a suitable framework to build the new control using pre existing elements.
  • 36. Custom Control Derive from a control or FrameworkElement class Selecting the correct base class is important Provide functionality and expose properties in code Provide ControlTemplate
  • 37. References WPF on CodePlex http://wpf.codeplex.com/
  • 38.  

Editor's Notes

  • #2: 06/10/09 15:29 © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.