Download presentation
Presentation is loading. Please wait.
Published byJesse Hamilton Modified over 6 years ago
1
MGB 2003 Adam Calderon – C# MVP Principal Engineer Interknowlogy
An Introduction to Styles and Templates in Windows Presentation Foundation (WPF) Adam Calderon – C# MVP Principal Engineer Interknowlogy © 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
2
What We Will Cover What Styles are and how to use them
MGB 2003 What We Will Cover 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 © 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
3
Session Prerequisites
MGB 2003 Session Prerequisites General Understanding of XML and XAML Basic knowledge of Microsoft® Windows® Presentation Foundation (WPF) Basic knowledge of WPF Resources Level 200 © 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
4
Agenda Styles Triggers Templates
MGB 2003 Agenda Styles Triggers Templates Adding Style to an existing application © 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
5
Styles Overview of Styles
MGB 2003 Styles Overview of Styles What are styles? Problems they address Elements that support styles © 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
6
Styles Style Class Properties
MGB 2003 Styles Style Class Properties Key TargetType Setters Property Event Resources Triggers © 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
7
Code Example of a Style <Style x:Key="Style1">
MGB 2003 Code Example of a Style <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" /> <TextBlock>Some Text</TextBlock> © 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
8
Styles Extending Styles
MGB 2003 Styles Extending Styles Order of Precedence BasedOn Property Style-based Element-based © 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
9
Demonstration One Styles in Action MGB 2003
© 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
10
Agenda Styles Triggers Templates
MGB 2003 Agenda Styles Triggers Templates Adding Style to an existing application © 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
11
Triggers Overview of Triggers
MGB 2003 Triggers Overview of Triggers Sets properties in response to end-user actions No code solution to code-based remedies of today © 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
12
Triggers Basics of Triggers
MGB 2003 Triggers 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 © 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
13
Demonstration Two Triggers in Action MGB 2003
© 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
14
Agenda Styles Triggers Templates
MGB 2003 Agenda Styles Triggers Templates Adding Style to an existing application © 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
15
Templates Overview of Templates
MGB 2003 Templates Overview of Templates Defines visual appearance of controls Out-of-box controls get their visual appearance from Templates Brings together styles and triggers © 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
16
Templates Basics of Templates
MGB 2003 Templates Basics of Templates Three types of templates: ControlTemplate ItemsPanelTemplate DataTemplate © 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
17
Templates Control Templates
MGB 2003 Templates Control Templates Resources TargetType Trigggers TemplateBinding links template and control properties ContentPresenter can be used to display controls content © 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
18
MGB 2003 Templates in Action
Demonstration Three Templates in Action © 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
19
Agenda Styles Triggers Templates
MGB 2003 Agenda Styles Triggers Templates Adding Style to an existing application © 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
20
Adding Style to an Application Steps
MGB 2003 Adding Style to an Application 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) © 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
21
MGB 2003 Transforming an Existing Application
Demonstration Four Transforming an Existing Application © 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
22
Session Summary Styles are powerful and flexible
MGB 2003 Session Summary Styles are powerful and flexible Triggers eliminate user interaction-based UI coding Controls are more about behavior Control Templates modify visual aspects of controls © 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
23
For More Information MSDN® Links Other Links
MGB 2003 For More Information MSDN® Links Microsoft Windows® Vista™ development center: Microsoft .NET Framework 3.0 for developers: Windows Presentation Foundation code-named "Avalon:” Other Links Microsoft .NET Framework: © 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
24
Additional Resources Applications = Code + Markup By Charles Petzold,
MGB 2003 Additional Resources Applications = Code + Markup By Charles Petzold, Microsoft Press® © 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
25
Adam Calderon More info on InterKnowlogy: www.InterKnowlogy.com
MGB 2003 Adam Calderon More info on InterKnowlogy: Contact Information Phone: x274 Blog: About Adam Calderon Microsoft MVP – C# Microsoft UI Server Frameworks Advisory Council Developer / Author / Speaker / Teacher © 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
26
Questions and Answers Submit text questions using the “Ask” button.
MGB 2003 Questions and Answers Submit text questions using the “Ask” button. Don’t forget to fill out the survey. For upcoming and previously live webcasts: Got webcast content ideas? Contact us at: Today's webcast was presented using Microsoft® Office Live Meeting. Get a free 14-day trial by visiting: © 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
27
MGB 2003 © 2003 Microsoft Corporation. All rights reserved.
This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.