59
Dave Bost Developer Evangelist http://davebost.com/blog

MSDN Unleashed: WPF Demystified

Embed Size (px)

Citation preview

Page 1: MSDN Unleashed: WPF Demystified

Dave BostDeveloper Evangelisthttp://davebost.com/blog

Page 2: MSDN Unleashed: WPF Demystified

http://thirstydeveloper.comhttp://thirstydeveloper.com

“Looking at someone’s code, but with audio”

Page 3: MSDN Unleashed: WPF Demystified

Essential concepts of Windows Presentation FoundationHow to create a data-bound, service based WPF application

Page 4: MSDN Unleashed: WPF Demystified

Level 100

User Interface development.NET language

VBC#

Familiar with XMLVisual Studio 2008

Page 5: MSDN Unleashed: WPF Demystified

Discover the top WPF benefits Creating a WPF applicationXAMLLayoutStylesUsing services and databasesData TemplatesUser ControlsControl Templates

Page 6: MSDN Unleashed: WPF Demystified

Composable ElementsFlexible layout enginePowerful data-binding architectureImpressive print, font and document capabilities

Page 7: MSDN Unleashed: WPF Demystified

Lookless controlsStyles and TemplatesFull integration of all UI disciplines

Page 8: MSDN Unleashed: WPF Demystified
Page 9: MSDN Unleashed: WPF Demystified

Manhattan Associates: Integrated Logistics Solutions (ILS)Supply Chain OptimizationStatus: Shipping Info: http://www.manh.com/ils_net/

Page 10: MSDN Unleashed: WPF Demystified

SilverWareSilverWare Avrio is a powerful hospitality industry solution with a highly intuitive GUI that makes it one of the most accessible P.O.S. solutions that restaurateurs and staff can use.Status: Shipping

Page 11: MSDN Unleashed: WPF Demystified

Eikos Partners: OpenTick Opentick is an open-source data provider that delivers free real-time and historical market data for trading systems and trading platforms.Status: Shipping

Page 12: MSDN Unleashed: WPF Demystified

Asahiyama Zoo Portal for the virtual exploration of one of Japan’s largest zoos.Status: Shipping Live Site: http://www.asahiyamazoo-aict.jp/asahiyamazoo.xbap

Page 13: MSDN Unleashed: WPF Demystified

YahooNext-generation instant messaging clientStatus: Public Beta

Page 14: MSDN Unleashed: WPF Demystified

Scripps HealthcareAllowing cancer researchers to collaborate in the search for a cureStatus: Late Beta (Shown at Windows Vista BV Launch)PR: .NET Developer’s Journal

Page 15: MSDN Unleashed: WPF Demystified

Electric Rain STANDOUTHigh-end tool for delivering visually stunning presentationsStatus: Beta

Page 16: MSDN Unleashed: WPF Demystified

Discover the top WPF benefits Creating a WPF applicationXAMLLayoutStylesUsing services and databasesData TemplatesUser ControlsControl Templates

Page 17: MSDN Unleashed: WPF Demystified

Create WPF application withVisual Studio 2008Expression Blend

A WPF application is managed codeIt runs on the .NET 2.0 runtime

Some classes similar to the WinForms modelApplication class Has Window class instead of Form classUse .Show() or .ShowDialog to display Page class for forward/back navigation

Host WinForms controls on WPF windowHost WPF controls on Winform forms

Page 18: MSDN Unleashed: WPF Demystified
Page 19: MSDN Unleashed: WPF Demystified

Discover the top WPF benefits Creating a WPF applicationXAMLLayoutStylesUsing services and databasesData TemplatesUser ControlsControl Templates

Page 20: MSDN Unleashed: WPF Demystified

XAML is a declarative programming languageTool friendly: Easy to persist UI structure in XAML

Expression Blend, ZAM 3D, Visual Studio

XAML is parsed by dedicated parserParser converts the tree of XML into a instances of objectsMost .NET types can be stored in XAML tree

Most likely that these will be Visual itemsWPF, Silverlight, XPS & Silverlight use XAML

Silverlight is a sub-set of WPF XAML

Page 21: MSDN Unleashed: WPF Demystified
Page 22: MSDN Unleashed: WPF Demystified
Page 23: MSDN Unleashed: WPF Demystified

Discover the top WPF benefits Creating a WPF applicationXAMLLayoutStylesUsing services and databasesData TemplatesUser ControlsControl Templates

Page 24: MSDN Unleashed: WPF Demystified

WPF includes a flexible, panel based layout engineWhat is layout?

Measuring and arranging a region of WPF UIAll layout is handled by panelsPanel has ultimate control over every child

Child size, location, ZOrderChild location relative to other children

Frees you from hard coding sizes/locationsMix and combine panels

Page 25: MSDN Unleashed: WPF Demystified

Child communicates with host panel via Attached propertiesInform their containing panel of desired layoutExample: Grid.Column = "3"Each panel handles one type of layoutGrid: Create rows/columns for childrenCanvas: Absolute positioningStackPanel: Children stacked horizontal/verticalDockPanel: Attach child to side of panelWrapPanel: Stacked, with multi children per line

Panel model is extensible with your own panels

Page 26: MSDN Unleashed: WPF Demystified

<Grid/><Grid/>

Page 27: MSDN Unleashed: WPF Demystified

<Canvas/><Canvas/>

Page 28: MSDN Unleashed: WPF Demystified

<StackPanel<StackPanel/>/>

Page 29: MSDN Unleashed: WPF Demystified

<StackPanel<StackPanel/>/>

Page 30: MSDN Unleashed: WPF Demystified

<DockPanel/<DockPanel/>>by lee.mccain.photorama

http://flickr.com/photos/mccain007/2218878568/

Page 31: MSDN Unleashed: WPF Demystified

<WrapPanel/<WrapPanel/>>

Page 32: MSDN Unleashed: WPF Demystified
Page 33: MSDN Unleashed: WPF Demystified

Discover the top WPF benefits Creating a WPF applicationXAMLLayoutStylesUsing services and databasesData TemplatesUser ControlsControl Templates

Page 34: MSDN Unleashed: WPF Demystified

Styles provide a convenient way to itemize a set of property values for an element type

Example: Set font attributes for all textboxesTo define a Style

Styles are defined in a Resource elementAny element in XAML can have a resource sectionUsual locations are Page, Window and Application levelEvery Style in resource must have a x:Key valueUse TargetType to limit style to one element type

Page 35: MSDN Unleashed: WPF Demystified

To apply a Style to an ElementReference the Style by setting the Style attributeUse the Markup Extension syntax '{}'

Page 36: MSDN Unleashed: WPF Demystified
Page 37: MSDN Unleashed: WPF Demystified

Discover the top WPF benefits Creating a WPF applicationXAMLLayoutStylesUsing services and databasesData TemplatesUser ControlsControl Templates

Page 38: MSDN Unleashed: WPF Demystified

Accessing data from WPFXMLDatabases

Ado.NETLinq to SQLLinq to EntitiesEntity Framework

Invoking Services from WPFWCFSoap, REST, WS*

Page 39: MSDN Unleashed: WPF Demystified

ADO.NET Data ServiceCode name Astoria Data ServicesExposes SQL data over HTTP via REST endpointsExamples: http://localhost/CohoDS.svc/Wines…Northwind.svc/Customers?$filter=contains(City,'Kent')

Authoring the Data ServiceWebsiteADO.NET EntityData modelADO.NET Data Service

Consuming the DataServiceGenerate proxy with DataSvcUtil.exeAdd proxy code to WPF application

Page 40: MSDN Unleashed: WPF Demystified
Page 41: MSDN Unleashed: WPF Demystified

Discover the top WPF benefits Creating a WPF applicationXAMLLayoutStylesUsing services and databasesData TemplatesUser ControlsControl Templates

Page 42: MSDN Unleashed: WPF Demystified

Binding overviewWPF synchronizes a data source and data targetAdd binding to target element with {Binding ***}

Change notificationWPF dependency system updates target upon source changes provided:

Source must implement change notificationVia IPropertyNotifyChanged and other mechanisms

Single bindingBind a target to a single property on sourceExample: TextBlock.Text to Customer.Age

List bindingBind a target to a array, collection etc.Example: Treeview. ItemsSource to XML source

Page 43: MSDN Unleashed: WPF Demystified

Templates provide a convenient way to centralize the replacement UI for:Tabular dataHierarchical dataControls

Data TemplateDefine the UI for one Type

Example: Customer classRender UI with six TextBlocks and one Image

Page 44: MSDN Unleashed: WPF Demystified
Page 45: MSDN Unleashed: WPF Demystified

Discover the top WPF benefits Creating a WPF applicationXAMLLayoutStylesUsing services and databasesData TemplatesUser ControlsControl Templates

Page 46: MSDN Unleashed: WPF Demystified

Custom elementsLess need for custom elements in WPFFirst consider getting custom look via

Composed UIStylesTemplates

If you must create custom element choose base:Existing controlControlUserControl

Page 47: MSDN Unleashed: WPF Demystified

User control benefitsSimpleEasy to compose sub-elements into new classEasily add custom element to UI tree

Control library authorCreate custom User ControlCompiled into assembly

Control consumerAdd reference to assemblyBring your namespace into scope with xmlns attribute

Page 48: MSDN Unleashed: WPF Demystified
Page 49: MSDN Unleashed: WPF Demystified

Discover the top WPF benefits Creating a WPF applicationXAMLLayoutStylesUsing services and databasesData TemplatesUser ControlsControl Templates

Page 50: MSDN Unleashed: WPF Demystified

All controls in WPF are looklessEach has a default UI templateWe can replace default template with our own control templateAny valid UI element can be part of templateTemplates also support bindingTemplates do not change behavior of element

Page 51: MSDN Unleashed: WPF Demystified
Page 52: MSDN Unleashed: WPF Demystified

WPF is a rich UI programming frameworkSince WPF is managed code, working with .NET APIs is easy and familiarCore concept is the composable UI model

Create UI out of any valid WPF elementMix and merge elements Formalize these replacement parts with Styles and Templates

Page 53: MSDN Unleashed: WPF Demystified

Visit MSDN at msdn.microsoft.com

Visit the URL below for additional information

http://windowsclient.net/

Virtual Labshttp://msdn.microsoft.com/virtuallabs

MIX Universityhttp://visitmix.com/university

Page 54: MSDN Unleashed: WPF Demystified

For the latest titles, visitwww.microsoft.com/learning/books/devtools

Page 55: MSDN Unleashed: WPF Demystified

These books can be found and purchased at all major book stores and online retailers

Page 56: MSDN Unleashed: WPF Demystified

Course ID Title

6460A Windows Presentation Foundation

For training information and availability www.microsoft.com/learning

Page 57: MSDN Unleashed: WPF Demystified

•Are you ready to take your career as a developer to the next level?

•Looking for a learning experience that is designed for you?

Join MSDN Ramp Up and Summit Your Career!

MSDN Ramp Up is your online source that provides free training and technical resources to help take your development skills to the next level.

• Step-by-Step training plans to build your development skills.

• Premium technical content created by expert developers for developers.

• Access to valuable online e-learning, e-references, and virtual labs.

• 50% discount on select certification exams and 30% discount on Microsoft Press training kits.

Join Ramp Up for free today! Go to: http://msdn.microsoft.com/rampup

Page 58: MSDN Unleashed: WPF Demystified

Dave [email protected]

thank you!

http://davebost.comhttp://twitter.com/davebost

Page 59: MSDN Unleashed: WPF Demystified

© 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.