36

NEXT: Overview – Sharing skills & code

Embed Size (px)

Citation preview

Page 1: NEXT: Overview – Sharing skills & code
Page 2: NEXT: Overview – Sharing skills & code

Sharing Skills and Code with Silverlight & WPF

Jeff WilcoxSoftware Development EngineerMicrosoft Corporation

Page 3: NEXT: Overview – Sharing skills & code

Sharing Skills and Code

Client Platform VisionWhat’s shared between Silverlight & WPF?Today’s controls and features

Silverlight controlsSilverlight ToolkitWPF Toolkit

Building controls for Silverlight & WPFBringing it all together

Page 4: NEXT: Overview – Sharing skills & code

Why?

Become a .NET expert onceChoice of .NET languagesGreat Microsoft toolsShared libraries and patterns

Develop a versatile skill setFlexibilityApply skills to RIA & LOBEfficient

Not about building apps that “work just” everywhere

Page 5: NEXT: Overview – Sharing skills & code

Client Platform Vision

Great platformsMaximize reach with SilverlightAdd value with WPF

Shared skills, techniques, vocabularyCreate once, use everywhere

XAML.NET codeTests

World-class developer & designer tools

Page 6: NEXT: Overview – Sharing skills & code

Current state of Microsoft Client Platforms

Silverlight 3Silverlight Toolkit.NET 4

We’re working to ensure compatibility

Page 7: NEXT: Overview – Sharing skills & code

You don’t have to be a code ninja!

Page 8: NEXT: Overview – Sharing skills & code

A simple shared app

demo

Page 9: NEXT: Overview – Sharing skills & code

What just happened?

Shared .NET platformShared development environment

Visual StudioBlend

Shared componentsPresentation platformRich charting and data grid controls

100% the same source code

Page 10: NEXT: Overview – Sharing skills & code

Shared Client Platform

Page 11: NEXT: Overview – Sharing skills & code

Shared Gu Technology

Page 12: NEXT: Overview – Sharing skills & code

Shared .NET Framework

Great application platformPowerful runtimeGreat language support

C#Visual BasicDynamic languages

PythonRuby

Amazing communities

Page 13: NEXT: Overview – Sharing skills & code

Business objects

Modern .NET business objects and logic “just work”

CollectionsGenericsLINQ

Easy to add framework-specific value

Page 14: NEXT: Overview – Sharing skills & code

Same references!

Page 15: NEXT: Overview – Sharing skills & code

Core Building Blocks

XAMLRich compositing

ShapesVisual tree

Managed frameworkDependency & attached propertiesEventsControl model

ControlsLayout

Page 16: NEXT: Overview – Sharing skills & code

Improving compatibility

Silverlight ToolkitMarch 2009 release

Silverlight 2 and Silverlight 3 releases available

Silverlight 2 development continuesWPF Toolkit

Available today.NET 4

Page 17: NEXT: Overview – Sharing skills & code

Silverlight Toolkit

Fills today’s slight compatibility gapDeveloping new controls with a rapid development cycleShips in the Silverlight SDK and on CodePlex

Page 18: NEXT: Overview – Sharing skills & code

Silverlight Toolkit

WPF compatible controlsDockPanelWrapPanelTreeView

WPF compatible featuresImplicitStyleManagerLayoutTransformer

New controls offered for Silverlight & WPF

ChartingAutoCompleteBox

Page 19: NEXT: Overview – Sharing skills & code

WPF Toolkit & .NET 4

CalendarDatePickerDataGridVisualStateManager

Page 20: NEXT: Overview – Sharing skills & code

Building controls

Page 21: NEXT: Overview – Sharing skills & code

Building controls

Step 1. Basics & C# strategyStep 2. Source layoutStep 3. Dependency propertiesStep 4. XAMLStep 5. Default stylesStep 6. VSMStep 7. Wild hacks

Page 22: NEXT: Overview – Sharing skills & code

Building controls

Step 1. Basics & C# strategyStep 2. Source layoutStep 3. Dependency propertiesStep 4. XAMLStep 5. Default stylesStep 6. VSMStep 7. Wild hacks

Page 23: NEXT: Overview – Sharing skills & code

C# Techniques

Partial classesExtension methods and utility classesPreprocessor directives

#if SILVERLIGHT// Silverlight

#else// WPF

#endif

Page 24: NEXT: Overview – Sharing skills & code

Source Layout

Peer folders for Silverlight & WPFFile links and source control

Silverlight\Control.csprojControl.csThemes\Generic.xaml

Wpf\Control.csprojControl.csThemes\Generic.xaml

Page 25: NEXT: Overview – Sharing skills & code

Dependency Properties

Avoid WPF-specific metadataCoercionRead-only properties

Page 26: NEXT: Overview – Sharing skills & code

Building controls

Step 1. Basics & C# strategyStep 2. Source layoutStep 3. Dependency propertiesStep 4. XAMLStep 5. Default stylesStep 6. VSMStep 7. Wild hacks

Page 27: NEXT: Overview – Sharing skills & code

XAML

Use WPF namespace

Watch out for the Silverlight 1.0 namespace

xmlns=“http://schemas.microsoft.com/winfx/2006/xaml/presentation”xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

http://schemas.microsoft.com/client/2007

Page 28: NEXT: Overview – Sharing skills & code

Building controls

Step 1. Basics & C# strategyStep 2. Source layoutStep 3. Dependency propertiesStep 4. XAMLStep 5. Default stylesStep 6. VSMStep 7. Wild hacks

Page 29: NEXT: Overview – Sharing skills & code

Default styles

Default styles and templates for controls are selected via DefaultStyleKey propertyDefined differently

WPF: Static constructorSilverlight: Instance constructor

Page 30: NEXT: Overview – Sharing skills & code

Building controls

Step 1. Basics & C# strategyStep 2. Source layoutStep 3. Dependency propertiesStep 4. XAMLStep 5. Default stylesStep 6. VSMStep 7. Wild hacks

Page 31: NEXT: Overview – Sharing skills & code

Building controls

Step 1. Basics & C# strategyStep 2. Source layoutStep 3. Dependency propertiesStep 4. XAMLStep 5. Default stylesStep 6. VSMStep 7. Wild hacks

Page 32: NEXT: Overview – Sharing skills & code

Wild hacks

Declare routed events in a partial classMyControl.Wpf.cs

Firing routed events      source.OnSelectionChanged(new

SelectionChangedEventArgs(#if SILVERLIGHT

SelectionChangedEvent,#endif

removed, added));

Page 33: NEXT: Overview – Sharing skills & code

Wild hacks

Helper extension methodsUtility classes

Abstract out application model differencesAbstract Client Platform differences

var x = new GlobalExceptionHandler(MyHandler);x.InterceptUnhandledExceptions = true;

Page 34: NEXT: Overview – Sharing skills & code

Putting it all together

demo

Page 35: NEXT: Overview – Sharing skills & code

Please complete session feedback!

Deck and demo will be posted tonight

Silverlight Toolkithttp://silverlight.codeplex.com/

Jeff Wilcox’s bloghttp://www.jeff.wilcox.name/

Page 36: NEXT: Overview – Sharing skills & code

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