An introduction to styles and templates in windows presentation foundation wpf
Download
1 / 26

an introduction to styles and templates in windows presentation foundation wpf - PowerPoint PPT Presentation


  • 449 Views
  • Uploaded on

An Introduction to Styles and Templates in Windows Presentation Foundation (WPF). Adam Calderon – C# MVP Principal Engineer Interknowlogy. What We Will Cover. What Styles are and how to use them How Triggers can be used to replace common UI behavior

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'an introduction to styles and templates in windows presentation foundation wpf' - albert


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
An introduction to styles and templates in windows presentation foundation wpf l.jpg

An Introduction to Styles and Templates in Windows Presentation Foundation (WPF)

Adam Calderon – C# MVP

Principal Engineer

Interknowlogy


What we will cover l.jpg
What We Will Cover Presentation Foundation (WPF)

  • What Styles are and how to use them

  • How Triggers can be used to replace common UI behavior

  • How Templates can be used to skin controls

  • How all of this comes together


Session prerequisites l.jpg
Session Prerequisites Presentation Foundation (WPF)

  • General Understanding of XML and XAML

  • Basic knowledge of Microsoft® Windows® Presentation Foundation (WPF)

  • Basic knowledge of WPF Resources

Level 200


Agenda l.jpg
Agenda Presentation Foundation (WPF)

  • Styles

  • Triggers

  • Templates

  • Adding Style to an existing application


Styles overview of styles l.jpg
Styles Presentation Foundation (WPF)Overview of Styles

  • What are styles?

  • Problems they address

  • Elements that support styles


Styles style class properties l.jpg
Styles Presentation Foundation (WPF)Style Class Properties

  • Key

  • TargetType

  • Setters

    • Property

    • Event

  • Resources

  • Triggers


Code example of a style l.jpg
Code Example of a Style Presentation Foundation (WPF)

<Style x:Key="Style1">

<Setter Property="Control.Background" Value="Yellow"/>

</Style>

<Label Content="Yellow Background" Style="{StaticResource Style1}" />

<Style TargetType="{x:Type TextBlock}">

<Setter Property="FontFamily" Value="Segoe Black" />

<Setter Property="HorizontalAlignment" Value="Center" />

<Setter Property="FontSize" Value="12pt" />

<Setter Property="Foreground" Value="#777777" />

</Style>

<TextBlock>Some Text</TextBlock>


Styles extending styles l.jpg
Styles Presentation Foundation (WPF)Extending Styles

  • Order of Precedence

  • BasedOn Property

    • Style-based

    • Element-based


Demonstration one l.jpg

Demonstration One Presentation Foundation (WPF)

Styles in Action


Agenda10 l.jpg
Agenda Presentation Foundation (WPF)

  • Styles

  • Triggers

  • Templates

  • Adding Style to an existing application


Triggers overview of triggers l.jpg
Triggers Presentation Foundation (WPF)Overview of Triggers

  • Sets properties in response to end-user actions

  • No code solution to code-based remedies of today


Triggers basics of triggers l.jpg
Triggers Presentation Foundation (WPF)Basics of Triggers

  • Property set must be a dependency property

  • Properties reset when trigger dependent property changes back

  • Supports single trigger entries and multiple trigger entries (composite trigger)

  • Supports triggers that are dependent upon data binding and not just standard property binding


Demonstration two l.jpg

Demonstration Two Presentation Foundation (WPF)

Triggers in Action


Agenda14 l.jpg
Agenda Presentation Foundation (WPF)

  • Styles

  • Triggers

  • Templates

  • Adding Style to an existing application


Templates overview of templates l.jpg
Templates Presentation Foundation (WPF)Overview of Templates

  • Defines visual appearance of controls

  • Out-of-box controls get their visual appearance from Templates

  • Brings together styles and triggers


Templates basics of templates l.jpg
Templates Presentation Foundation (WPF)Basics of Templates

  • Three types of templates:

    • ControlTemplate

    • ItemsPanelTemplate

    • DataTemplate

  • TemplateBinding links template and control properties

  • ContentPresenter can be used to display controls content


Demonstration three l.jpg

Demonstration Three Presentation Foundation (WPF)

Templates in Action


Agenda18 l.jpg
Agenda Presentation Foundation (WPF)

  • Styles

  • Triggers

  • Templates

  • Adding Style to an existing application


Adding style to an application steps l.jpg
Adding Style to an Application Presentation Foundation (WPF)Steps

  • Use Style Setters to change the appearance of the text blocks

  • Use Control Templates to redefine the visual tree of a control

  • Use Data Templates to determine how the data appears

  • Use Triggers to create dynamic user interface (UI)


Demonstration four l.jpg

Demonstration Four Presentation Foundation (WPF)

Transforming an Existing Application


Session summary l.jpg
Session Summary Presentation Foundation (WPF)

  • Styles are powerful and flexible

  • Triggers eliminate user interaction-based UI coding

  • Controls are more about behavior

  • Control Templates modify visual aspects of controls


For more information l.jpg
For More Information Presentation Foundation (WPF)

  • MSDN® Links

    Microsoft Windows® Vista™ development center: http://msdn.microsoft.com/windowsvista/

    Microsoft .NET Framework 3.0 for developers: http://msdn.microsoft.com/winfx/

    Windows Presentation Foundation code-named "Avalon:” http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=119&SiteID=1

  • Other Links

    Microsoft .NET Framework: http://www.netfx3.com/


Additional resources l.jpg
Additional Resources Presentation Foundation (WPF)

Applications = Code + Markup

By Charles Petzold,

Microsoft Press®


Adam calderon l.jpg
Adam Calderon Presentation Foundation (WPF)

  • More info on InterKnowlogy:www.InterKnowlogy.com

  • Contact Information

    E-mail: [email protected]

    Phone: 760-930-0075 x274

    Blog: http://blogs.InterKnowlogy.com/AdamCalderon

  • About Adam Calderon

    • Microsoft MVP – C#

    • Microsoft UI Server Frameworks Advisory Council

    • Developer / Author / Speaker


Questions and answers l.jpg
Questions and Answers Presentation Foundation (WPF)

  • Submit text questions using the “Ask” button.

  • Don’t forget to fill out the survey.

  • For upcoming and previously live webcasts: www.microsoft.com/webcasts

  • Got webcast content ideas? Contact us at: http://go.microsoft.com/fwlink/?LinkId=41781

  • Today's webcast was presented using Microsoft® Office Live Meeting. Get a free 14-day trial by visiting: www.microsoft.com/presentlive


ad