Upload
aubrie-holland
View
227
Download
0
Tags:
Embed Size (px)
Citation preview
Sharing Skills and Code with Silverlight & WPF
Jeff WilcoxSoftware Development EngineerMicrosoft Corporation
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
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
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
Current state of Microsoft Client Platforms
Silverlight 3Silverlight Toolkit.NET 4
We’re working to ensure compatibility
You don’t have to be a code ninja!
A simple shared app
demo
What just happened?
Shared .NET platformShared development environment
Visual StudioBlend
Shared componentsPresentation platformRich charting and data grid controls
100% the same source code
Shared Client Platform
Shared Gu Technology
Shared .NET Framework
Great application platformPowerful runtimeGreat language support
C#Visual BasicDynamic languages
PythonRuby
Amazing communities
Business objects
Modern .NET business objects and logic “just work”
CollectionsGenericsLINQ
Easy to add framework-specific value
Same references!
Core Building Blocks
XAMLRich compositing
ShapesVisual tree
Managed frameworkDependency & attached propertiesEventsControl model
ControlsLayout
Improving compatibility
Silverlight ToolkitMarch 2009 release
Silverlight 2 and Silverlight 3 releases available
Silverlight 2 development continuesWPF Toolkit
Available today.NET 4
Silverlight Toolkit
Fills today’s slight compatibility gapDeveloping new controls with a rapid development cycleShips in the Silverlight SDK and on CodePlex
Silverlight Toolkit
WPF compatible controlsDockPanelWrapPanelTreeView
WPF compatible featuresImplicitStyleManagerLayoutTransformer
New controls offered for Silverlight & WPF
ChartingAutoCompleteBox
WPF Toolkit & .NET 4
CalendarDatePickerDataGridVisualStateManager
Building controls
Building controls
Step 1. Basics & C# strategyStep 2. Source layoutStep 3. Dependency propertiesStep 4. XAMLStep 5. Default stylesStep 6. VSMStep 7. Wild hacks
Building controls
Step 1. Basics & C# strategyStep 2. Source layoutStep 3. Dependency propertiesStep 4. XAMLStep 5. Default stylesStep 6. VSMStep 7. Wild hacks
C# Techniques
Partial classesExtension methods and utility classesPreprocessor directives
#if SILVERLIGHT// Silverlight
#else// WPF
#endif
Source Layout
Peer folders for Silverlight & WPFFile links and source control
Silverlight\Control.csprojControl.csThemes\Generic.xaml
Wpf\Control.csprojControl.csThemes\Generic.xaml
Dependency Properties
Avoid WPF-specific metadataCoercionRead-only properties
Building controls
Step 1. Basics & C# strategyStep 2. Source layoutStep 3. Dependency propertiesStep 4. XAMLStep 5. Default stylesStep 6. VSMStep 7. Wild hacks
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
Building controls
Step 1. Basics & C# strategyStep 2. Source layoutStep 3. Dependency propertiesStep 4. XAMLStep 5. Default stylesStep 6. VSMStep 7. Wild hacks
Default styles
Default styles and templates for controls are selected via DefaultStyleKey propertyDefined differently
WPF: Static constructorSilverlight: Instance constructor
Building controls
Step 1. Basics & C# strategyStep 2. Source layoutStep 3. Dependency propertiesStep 4. XAMLStep 5. Default stylesStep 6. VSMStep 7. Wild hacks
Building controls
Step 1. Basics & C# strategyStep 2. Source layoutStep 3. Dependency propertiesStep 4. XAMLStep 5. Default stylesStep 6. VSMStep 7. Wild hacks
Wild hacks
Declare routed events in a partial classMyControl.Wpf.cs
Firing routed events source.OnSelectionChanged(new
SelectionChangedEventArgs(#if SILVERLIGHT
SelectionChangedEvent,#endif
removed, added));
Wild hacks
Helper extension methodsUtility classes
Abstract out application model differencesAbstract Client Platform differences
var x = new GlobalExceptionHandler(MyHandler);x.InterceptUnhandledExceptions = true;
Putting it all together
demo
Please complete session feedback!
Deck and demo will be posted tonight
Silverlight Toolkithttp://silverlight.codeplex.com/
Jeff Wilcox’s bloghttp://www.jeff.wilcox.name/
© 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.