windows presentation foundation ("avalon"): beautiful code, beautiful design -...

48
Windows Presentation Foundation Windows Presentation Foundation ("Avalon"): Beautiful Code, ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Beautiful Design - Applications Your Designers Can Work With Designers Can Work With Robert Ingebretsen Robert Ingebretsen PRS317 PRS317 Program Manager, WPF Program Manager, WPF Microsoft Corporation Microsoft Corporation

Upload: barnard-hampton

Post on 19-Jan-2016

226 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

Windows Presentation Foundation Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work - Applications Your Designers Can Work WithWith

Robert IngebretsenRobert IngebretsenPRS317PRS317Program Manager, WPFProgram Manager, WPFMicrosoft CorporationMicrosoft Corporation

Page 2: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

89Percentage of business readers who Percentage of business readers who called designcalled design “an essential way to “an essential way to

make lasting connections with make lasting connections with consumers”consumers”

Source: Source: Fast CompanyFast Company magazine, June 2005 magazine, June 2005

%

Page 3: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program
Page 4: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program
Page 5: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program
Page 6: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

good enough.good enough.

Page 7: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

good enough, meet…good enough, meet…

great!great!

Page 8: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

powerfulpowerful visual and interactive visual and interactive

capabilitiescapabilities

cleanclean separation of UI and logicseparation of UI and logic

great toolsgreat tools for developers and designersfor developers and designers

Page 9: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

PhotoStore Basic UIPhotoStore Basic UI

Page 10: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

developer / designer workflowdeveloper / designer workflow

Page 11: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

Designer DetailsDesigner DetailsLost in TranslationLost in Translation

Page 12: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

while (!design.IsPerfect)while (!design.IsPerfect)

{{

Designer.CreateNewDesign();Designer.CreateNewDesign();

Developer.ImplementNewDesignDeveloper.ImplementNewDesign();();

design.IsPerfect = false;design.IsPerfect = false;

}}

Page 13: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

while (!design.IsPerfect)while (!design.IsPerfect)

{{

Designer.CreateNewDesign();Designer.CreateNewDesign();

Developer.ImplementNewDesignDeveloper.ImplementNewDesign();();

design.IsPerfect = false;design.IsPerfect = false;

if (Schedule.SlipCount >= x) if (Schedule.SlipCount >= x) break;break;

}}

Page 14: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

designer: designer: independentindependent UI creator UI creator

no more “translation” errorsno more “translation” errorsparallel workflowparallel workflow

realtime iteration and feedbackrealtime iteration and feedback

Page 15: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

Window1.xaml.csWindow1.xaml.cs

Contains:Contains:Application logicApplication logic

Created by:Created by:Application Application developerdeveloper

Window1.xamlWindow1.xaml

Contains:Contains:Principal UIPrincipal UI

(controls, layout, (controls, layout, etc.)etc.)

Created by:Created by:Application Application

developer developer oror designerdesigner

Design Design Experience:Experience:

By hand or using a By hand or using a visual toolvisual tool

Styles.xamlStyles.xaml

Contains:Contains:Application “style”Application “style”(visual description (visual description

of UI elements)of UI elements)

Created by:Created by:Application Application designerdesigner

Design Design Experience:Experience:

By hand or using a By hand or using a visual toolvisual tool

projectproject structurestructure

Data model, event names, Data model, event names, element names, etc.element names, etc.

Resource names and Resource names and element types.element types.

Page 16: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

PhotoStore ProjectPhotoStore Project

Page 17: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

stylingstyling is… is…

resourcesresourcesstylesstyles

templatestemplatestriggerstriggers

storyboardsstoryboards

Page 18: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

stylesstyles

centrally define the centrally define the appearanceappearance and and interactive behaviorsinteractive behaviors of the of the

elements in your appelements in your app

Page 19: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

stylestyle drilldown drilldown

lookup key can be a lookup key can be a name name or a or a type type

Styled ButtonStyled Button

<Style x:Key=“<Style x:Key=“MyStyleMyStyle” TargetType=“” TargetType=“{x:Type {x:Type Button}Button}”>”>

</Style></Style>

Page 20: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

stylestyle drilldown drilldown

lookup key can be a lookup key can be a name name or a or a type type

Styled ButtonStyled Button

<Style TargetType=“<Style TargetType=“{x:Type Button}{x:Type Button}”>”>

</Style></Style>

Page 21: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

stylestyle drilldown drilldown

use <Setter> to set properties onuse <Setter> to set properties onthe styled elementthe styled element

Styled ButtonStyled Button

<Style x:Key=“MyStyle” TargetType=“{x:Type Button}”><Style x:Key=“MyStyle” TargetType=“{x:Type Button}”> <Setter Property=“Background” Value=“Green” /><Setter Property=“Background” Value=“Green” /></Style></Style>

Page 22: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

stylestyle drilldown drilldown

styles can be based on other stylesstyles can be based on other styles

Styled ButtonStyled Button

<Style <Style x:Key=“BaseStyle”x:Key=“BaseStyle” > > <Setter Property=“Foreground” Value=“Orange” /><Setter Property=“Foreground” Value=“Orange” /></Style></Style>

<Style x:Key=“MyStyle” <Style x:Key=“MyStyle” BasedOn=“{StaticResource BasedOn=“{StaticResource BaseStyle}”BaseStyle}” /> /> <Setter Property=“Background” Value=“Green” /><Setter Property=“Background” Value=“Green” /></Style></Style>

Page 23: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

Styles and ResourcesStyles and Resources

Page 24: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

templatestemplates

describe the visual describe the visual structurestructure of a controlof a control

Page 25: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

templatetemplate drilldown drilldown

control introduces the control introduces the Template propertyTemplate propertywhich defines the control’s which defines the control’s structure structure and and

appearanceappearance

<Button <Button Template=“{StaticResource Template=“{StaticResource MyButton}”MyButton}” /> />

Page 26: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

templatetemplate drilldown drilldown

use use composition composition to describe to describe the control’s the control’s visual treevisual tree

TemplatedTemplatedButtonButton

<ControlTemplate x:Key=“MyButton” TargetType=“{x:Type <ControlTemplate x:Key=“MyButton” TargetType=“{x:Type Button}”>Button}”> <Grid><Grid> <Ellipse /><Ellipse /> <ContentPresenter /><ContentPresenter /> </Grid></Grid></ControlTemplate></ControlTemplate>

<Button Template=“{StaticResource MyButton}” /><Button Template=“{StaticResource MyButton}” />

Page 27: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

templatetemplate drilldown drilldown

use use contract elements contract elements to ensure to ensure correct functionalitycorrect functionality

TemplatedTemplatedButtonButton

<ControlTemplate x:Key=“MyButton” TargetType=“{x:Type <ControlTemplate x:Key=“MyButton” TargetType=“{x:Type Button}”>Button}”> <Grid><Grid> <Ellipse /><Ellipse /> <ContentPresenter /><ContentPresenter /> </Grid></Grid></ControlTemplate></ControlTemplate>

<Button Template=“{StaticResource MyButton}” /><Button Template=“{StaticResource MyButton}” />

Page 28: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

templatetemplate drilldown drilldown

use <DataTemplates> to define a visualuse <DataTemplates> to define a visualrepresentation of a data objectrepresentation of a data object

<DataTemplate <DataTemplate DataType=“{x:Type DataType=“{x:Type PhotoObject}”PhotoObject}”>> <Image Source<Image Source=“{Binding FileName}”=“{Binding FileName}” /> /></ControlTemplate></ControlTemplate>

Page 29: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

TemplatesTemplates

Page 30: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

triggers and storyboardstriggers and storyboards

Use with styles and templates toUse with styles and templates tocreate create rich rich and and dynamic dynamic

interactioninteraction

Page 31: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

triggers and storyboardstriggers and storyboards drilldown drilldown

triggers are triggers are activatedactivated when a specified when a specified condition condition becomes truebecomes true

<Trigger <Trigger Property=“IsMouseOver” Value=“true”Property=“IsMouseOver” Value=“true”>> </Trigger></Trigger>

Page 32: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

triggers and storyboardstriggers and storyboards drilldown drilldown

define “triggered” define “triggered” property changes property changes using using <Setter> <Setter>

(the previous state gets cached)(the previous state gets cached)

Styled ButtonStyled Button

<Trigger Property=“IsMouseOver” Value=“true”><Trigger Property=“IsMouseOver” Value=“true”> <Setter Property=“Background” <Setter Property=“Background” Value=“Orange” />Value=“Orange” /></Trigger></Trigger>

Page 33: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

triggers and storyboardstriggers and storyboards drilldown drilldown

use use storyboardsstoryboards with <EventTrigger> to with <EventTrigger> to add add dynamic animationsdynamic animations

Styled ButtonStyled Button

<EventTrigger RoutedEvent=“Mouse.Enter”><EventTrigger RoutedEvent=“Mouse.Enter”> <Storyboard TargetProperty=“MaxWidth”><Storyboard TargetProperty=“MaxWidth”> <DoubleAnimation Duration=“0:0:1” <DoubleAnimation Duration=“0:0:1” To=“150” /> To=“150” /> </Storyboard></Storyboard></EventTrigger></EventTrigger>

Page 34: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

Storyboards and TriggersStoryboards and Triggers

Page 35: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program
Page 36: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program
Page 37: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

Window1.xaml.csWindow1.xaml.cs

Contains:Contains:Application logicApplication logic

Created by:Created by:Application Application developerdeveloper

Window1.xamlWindow1.xaml

Contains:Contains:Principal UIPrincipal UI

(controls, layout, (controls, layout, etc.)etc.)

Created by:Created by:Application Application

developer developer oror designerdesigner

Design Design Experience:Experience:

By hand or using a By hand or using a visual toolvisual tool

Styles.xamlStyles.xaml

Contains:Contains:Application “style”Application “style”(visual description (visual description

of UI elements)of UI elements)

Created by:Created by:Application Application designerdesigner

Design Design Experience:Experience:

By hand or using a By hand or using a visual toolvisual tool

projectproject structurestructure

Page 38: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

Window1.xaml.Window1.xaml.cscs

Contains:Contains:Application logicApplication logic

Created by:Created by:Application Application developerdeveloper

Window1.xamlWindow1.xamlProfessionalProfessional

VersionVersion

Window1.xamlWindow1.xamlConsumerConsumer

VersionVersion

Window1.xamlWindow1.xamlMCEMCE VersionVersion

targeted experiencestargeted experiences

Page 39: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

Keyword: Keyword: targetedtargeted

Page 40: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

Targeted ExperiencesTargeted Experiences

Page 41: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

with power comes responsibilitywith power comes responsibility

Page 42: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

HTMLThe Early Years

Page 43: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

Font Font SaladSaladFrankly,Frankly,

Page 44: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

building great software with WPFbuilding great software with WPF

Start with Start with what you knowwhat you know

Involve a Involve a designerdesigner when in when in unchartered territoryunchartered territory

Remember that your Remember that your brand is the brand is the entire experienceentire experience

Make software that Make software that lastslasts—just as —just as enjoyable enjoyable the 100th time as the 1stthe 100th time as the 1st

Create apps that are Create apps that are appropriateappropriate for the intended audience or userfor the intended audience or user

Draw focus to Draw focus to hero hero and and McGuffin McGuffin momentsmoments

Page 45: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

Good design means that Good design means that beauty beauty andandusability usability are in are in balancebalance. .

Donald A. Norman, Interactions, July/August 2002Donald A. Norman, Interactions, July/August 2002

Page 46: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

related talksrelated talks

databinding: databinding: PRS324 (Thursday, 3:45)PRS324 (Thursday, 3:45)building controls:building controls: PRS431 (Friday, 10:30) PRS431 (Friday, 10:30)

layout: layout: PRS329 (Thursday, 5:15)PRS329 (Thursday, 5:15)rich content: rich content: PRS330 (Friday, 8:30)PRS330 (Friday, 8:30)

designer tool overview:designer tool overview: TLN213 (Thursday, 11:30) TLN213 (Thursday, 11:30)

meme

email:email: [email protected] [email protected]:blog: http://www.notstatic.com http://www.notstatic.com

demo source:demo source: http://www.notstatic.com/pdc2005 http://www.notstatic.com/pdc2005

Page 47: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

thank you.thank you.

Page 48: Windows Presentation Foundation ("Avalon"): Beautiful Code, Beautiful Design - Applications Your Designers Can Work With Robert Ingebretsen PRS317 Program

© 2005 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.