xaml: one language to rule them all
DESCRIPTION
TRANSCRIPT
XAML One Language to Rule Them All
XAML One Language to Rule Them All
Frank La VigneLead DesignerApplied Information Scienceshttp://www.franksworld.com
Ego Slide
Frank La Vigne Microsoft MVP: Tablet PC INETA Membership Mentor for DC,
Maryland and Delaware Manager DC Silverlight SIG Lead Designer @ AIS
Blog: www.franksworld.com Company: www.appliedis.com Twitter: @Tableteer
Feedback [email protected]
Goals
The 3 R’s of Client Development
Reach RIA Rich
Client Continuum
Reach: The Web
Widest possible reachFrom text only devices to desktops;from laptops to mobile phones;the web works just about anywhere
Platform/Browser Independent**Write once, test everywhere in every
conceivable combination.Hard to debugEasy to DeployUser experience varies
Rich: Windows Client Application
Richest experience possibleResponse time is instantaneousWPF applications can leverage hardware acceleration for some truly engaging user experiences
Easy to DebugNarrow focusDeployment concerns
RIA: Silverlight Applications
Happy Medium of Reach and RichResponse time is instantaneousRuns on Windows, Mac and Linux
Easy to DebugWide focusEasy deploymentEnables great user experiences
But Wait, There’s More!
MORE!
The Fantastic Four of Client Technology
Reach RIA XBAP Rich
XAML
Client Continuum
Silverlight Out of Browser Applications
NEW IN VERSION 3
XBAP?
What’s an
XBAP?
XBAP Defined
Slightly Better Reach, a Lot More RichAll the benefits of SilverlightThe Power of WPF in a browser window
3D, Drag & Drop, Printing, Hardware Acceleration
Easy to DebugEasy deployment (Windows w/ .NET 3.x)Enables great user experiences
When to Use XBAPs
To quickly push a WPF app onto the webWhen Management demands that applications be web basedWhen Windows is the client platform
Ideal for corporate intranetSpecialized applicationsQuickly moving a WPF application to the web
Demo
"Sawdust"
How Can I Create an XBAP?Open Visual Studio 2008
File New Project WPF Browser Application
How Do I Deploy an XBAP?In Visual Studio 2008
Build Publish
Deploying an XBAP: Mime Types
MIME Type File Extensionapplication/manifest .manifestapplication/x-ms-xbap .xbapapplication/octet-stream .deployapplication/x-ms-application .applicationapplication/vnd.ms-xpsdocument .xpsapplication/xaml-xml .xaml
REMEMBER TO SET THE FOLLOWING MIME TYPES ON YOUR SERVER
Demo
Let the LOLCats Guide Us
Creating &Publishing anXBAP Application
3-2-1 Launch!
Three Choices for Client Applications Two Core Technologies One Common
Language
XAML Powers It All
One Markup Language to Rule Them All
Mostly the Same
WPF OnlyGapsSilverlight OnlyShared
But the Differences Will Get You
WPF OnlyGapsSilverlight OnlyShared
Caution: Eye Charts Ahead!
Different Feature Sets..
3D Documents Drag Drop Win32 Interop Triggers Commands Printing Logical tree Adorners Hosting WebBrowser
Deep Zoom VC-1 codec H.264 codec 3 HTML integration Sandbox VideoBrush Plane Projection 3
Graphics
Hardware acceleration Graphics are
Drawings Streams Shapes
Hardware acceleration 3 Multi-core optimizations Lighter weight visuals Graphics are
Shapes
Property System
More inherited properties Extensible
Property Metadata Default Values Coercion
Resources
generic.xaml Delayed instantiation of
StaticResources Merged Resource
Dictionaries FindResource walks
the tree Freezables
generic.xaml XamlReader can load
Resource Dictionaries.
Databinding
UIElement to UIElement bindings MultiBinding Binding support at DependencyObject
Dictionaries Relative bindings Template selectors More Type converters out of the box
UIElement to UIElement bindings 3
Binding support at FrameworkElement No TargetType on data templates
Eventing
Events are synchronous Tunneling (Preview) events Mouse Wheel
Events are asynchronous Not all events bubble, even
if declared as Routed
Styles
Write-once No app themes No BasedOn No triggers
Animation
MotionPath AnimationCompositionTarget.Rendering More animatable types ExtensibilityStoryboard APIs added in 3.5 SP1
Named key-framesStoryboard APIs
Begin, Stop, etc.
Input
Support for other platforms Key.Unknown ModifierKeys.Apple KeyEventArgs.PlatformKeyCode
Layout
LayoutTransform Text measures early
Other
More markup-extensions e.g. x:Static
More panels
Different Hit-Testing LayoutRounding Property No XamlWriter No VisualBrush No OnRender
Demo
Enough Slides!Code Time
WPF XBAP WPF Silverlight
Tips & Tricks for Recycling XAML
Source compatibility (not binary compatibility)
It is a different frameworkCode to Silverlight
(Common Denominator)Create a different VS project for each ‘run-time’
Link the files together
Use WPF’s XML namespace declarationxmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Tips & Tricks for Recycling Source Code
Use #if for small logic Move all conditional logic to code (no #if in XAML)
Partial classes for larger chunksCan use separate files altogether
Place Templates and styles in App.xaml (both platforms can pick from there)
Other API differences
OpenFileDialog SL = System.Windows.ControlsWPF: Microsoft.Win32
Dispatcher.BeginInvoke different signaturesSL has more classes sealed (can’t be inherited) XamlReader.Load
SL = XamlReader.Load ( string ) WPF = XamlReader.Load ( stream )
Other API differences (cont’d)
ContentPresenterSL : class ContentPresenter : Control WPF : class ContentPresenter : FrameworkElement
UIElementCollection SL : UIElementCollection : PresentationFrameworkCollection<UIElement>WPF : UIElementCollection : IList, ICollection, Ienumerable