Silverlight 2


Published on

This deck provides an overview for .NET developers in how to create Silverlight 2 applications.

Published in: Technology, Education
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Hello and Welcome to this MSDN session on {insert session title}. My name is {insert name} Let us start this session by going into more detail on exactly what we will be covering.
  • Silverlight 2

    1. 1. Dave Bost Developer Evangelist
    2. 2. <ul><li>Where did Silverlight come from and what can it really do </li></ul><ul><li>What is XAML and how does it aid in UI authoring </li></ul><ul><li>What controls ship with Silverlight and how can they be styled and data-bound </li></ul><ul><li>What functionality is available in the Silverlight Base Class Library </li></ul>
    3. 3. <ul><li>Visual Studio 2008 </li></ul><ul><li>Silverlight 2 Runtime </li></ul><ul><li>Microsoft Silverlight Tools for for VS2008 </li></ul><ul><li>Other useful stuff </li></ul><ul><ul><li>Silverlight 2 SDK (installed with tools install) </li></ul></ul><ul><ul><li>Expression Studio 2 (Blend SP1) </li></ul></ul><ul><ul><li>Deep Zoom Composer </li></ul></ul><ul><ul><li>Silverlight 2 Controls Source Code + Unit Tests </li></ul></ul>
    4. 4. <ul><li>Introduction to Silverlight </li></ul><ul><li>XAML </li></ul><ul><li>Controls </li></ul><ul><li>Base Class Library </li></ul>
    5. 5. <ul><li>Formerly known as &quot;WPF/E&quot; </li></ul><ul><li>Microsoft's platform for rich, highly interactive Web experiences and RIAs </li></ul><ul><ul><li>Cross-platform (browsers and OSes) </li></ul></ul><ul><ul><ul><li>Windows, Mac OS, Linux (&quot;Moonlight&quot;) </li></ul></ul></ul><ul><ul><ul><li>Internet Explorer, Firefox, Safari, and more </li></ul></ul></ul><ul><ul><li>XAML-based rendering (subset of WPF XAML) </li></ul></ul><ul><li>Implemented as browser plug-in </li></ul><ul><ul><li>Quick, easy install experience </li></ul></ul>
    6. 6. <ul><li>Silverlight 1.0 </li></ul><ul><ul><li>Shipped September 2007 </li></ul></ul><ul><ul><li>XAML rendering and JavaScript API </li></ul></ul><ul><li>Silverlight 2 </li></ul><ul><ul><li>Shipped October 2008 </li></ul></ul><ul><ul><li>XAML, .NET Framework, managed code, dynamic languages (e.g., IronPython, IronRuby) </li></ul></ul>
    7. 8. <ul><li>Refactored version of full-size CLR </li></ul><ul><ul><li>Same core type system, JIT compiler, etc. </li></ul></ul><ul><ul><li>COM interop, remoting, binary serialization, server GC, and other features removed </li></ul></ul><ul><ul><li>CAS replaced with transparency model </li></ul></ul><ul><ul><li>Multiple CLR instances per process supported </li></ul></ul><ul><ul><li>Most globalization support pushed down to OS </li></ul></ul><ul><ul><li>Dynamic Language Runtime (DLR) added </li></ul></ul><ul><li>Small footprint (< 2MB), cross-platform </li></ul>
    8. 9. System.Windows System.Windows.Controls System.Windows.Input System.Windows.Interop System.Windows.Media System.Windows.Shapes System.Windows.Threading System.Windows.Browser System System.Collections System.Collections.Generic System.Diagnostics System.Globalization System.IO System.IO.- IsolatedStorage System.Reflection System.Security System.Security.Cryptography System.Text System.Threading System System.Collections.Generic System.ComponentModel System.Diagnostics System.Text.RegularExpressions System.Linq System.Linq.Expressions System.Runtime.CompilerServices System.Security.Cryptography System.Xml System.XmlSchema System.Xml.Serialization
    9. 10. Web project generated by Visual Studio for testing and debugging Main project HTML test page XAML file containing global (application) resources and event handlers XAML file containing &quot;page&quot; seen by user XAP file containing application assembly, library assemblies, and resources
    10. 11. <object id=&quot;SilverlightControl&quot; data=&quot;data:application/x-silverlight&quot; type=&quot;application/x-silverlight-2-b2&quot; width=&quot;100%&quot; height=&quot;100%&quot;> <param name=&quot;source&quot; value=&quot;ClientBin/SilverLife.xap&quot; /> </object> OBJECT tag Application package Control DOM ID MIME type Control version Width and height XAP file containing application assembly, resources, etc.
    11. 12. <Canvas Width=&quot;300&quot; Height=&quot;300&quot; xmlns=&quot;; xmlns:x=&quot;;> <Ellipse Canvas.Left=&quot;20&quot; Canvas.Top=&quot;20&quot; Height=&quot;200&quot; Width=&quot;200&quot; Stroke=&quot;Black&quot; StrokeThickness=&quot;10&quot; Fill=&quot;Yellow&quot; /> <Ellipse Canvas.Left=&quot;80&quot; Canvas.Top=&quot;80&quot; Height=&quot;35&quot; Width=&quot;25&quot; Stroke=&quot;Black&quot; Fill=&quot;Black&quot; /> <Ellipse Canvas.Left=&quot;140&quot; Canvas.Top=&quot;80&quot; Height=&quot;35&quot; Width=&quot;25&quot; Stroke=&quot;Black&quot; Fill=&quot;Black&quot; /> <Path Data=&quot;M 70, 150 A 60, 60 0 0 0 170, 150&quot; Stroke=&quot;Black&quot; StrokeThickness=&quot;15&quot; StrokeStartLineCap=&quot;Round&quot; StrokeEndLineCap=&quot;Round&quot; /> </Canvas>
    12. 13. <ul><li>XAML objects fire events </li></ul><ul><ul><li>Canvases and UI objects fire Loaded events and mouse events (e.g., MouseLeftButtonDown) </li></ul></ul><ul><ul><li>Root canvas also fires keyboard events </li></ul></ul><ul><ul><li>Other objects fire object-specific events </li></ul></ul><ul><li>Handlers can be registered declaratively or programmatically </li></ul><ul><li>Mouse events &quot;bubble up&quot; through XAML object hierarchy </li></ul>
    13. 14. <ul><li>Layout is driven by Panel objects </li></ul><ul><ul><li>Every page has a root Grid object </li></ul></ul><ul><ul><li>Page can contain additional Grids or Canvases </li></ul></ul><ul><li>Panels are a containers for other UI elements </li></ul><ul><ul><li>Grids, StackPanel, Canvas are types of panels </li></ul></ul><ul><li>All units measured in logical pixels </li></ul>
    14. 15. <Grid/>
    15. 16. <Canvas/>
    16. 17. <StackPanel/>
    17. 18. <StackPanel/>
    18. 19. <ul><li>Silverlight supports six shapes </li></ul>Rectangle Ellipse Polygon Line PolyLine Path
    19. 20. <ul><li>Audio/video playback in a box </li></ul><ul><ul><li>Progressive downloads and streaming </li></ul></ul><ul><li>Robust API provides basis for rich UIs </li></ul><ul><ul><li>Play, Pause, Stop, and other methods </li></ul></ul><ul><ul><li>Position, Volume, and other properties </li></ul></ul><ul><ul><li>DownloadProgressChanged and other events </li></ul></ul><ul><li>WMV1/2/3/A/VC1, WMA, and MP3 </li></ul>
    20. 21. TranslateTransform RotateTransform SkewTransform ScaleTransform
    21. 22. <ul><li>Animations are created by varying properties of XAML objects over time </li></ul><ul><ul><li>From/To animations vary properties linearly </li></ul></ul><ul><ul><li>Key-frame animations use discrete steps </li></ul></ul><ul><li>Animation objects define animations </li></ul><ul><ul><li>DoubleAnimation[UsingKeyFrames] </li></ul></ul><ul><ul><li>ColorAnimation[UsingKeyFrames] </li></ul></ul><ul><ul><li>PointAnimation[UsingKeyFrames] </li></ul></ul><ul><li>StoryBoard objects hold animation objects </li></ul>
    22. 24. <ul><li>Created a smiley face object using Expression Blend </li></ul><ul><li>Applied an animation to the smiley face object </li></ul><ul><li>Added some event handling to the smiley face using Visual Studio </li></ul>
    23. 25. <ul><li>More than 20 built-in controls </li></ul><ul><ul><li>Canvas, StackPanel, Grid, and GridSplitter </li></ul></ul><ul><ul><li>Button, CheckBox, HyperlinkButton, RepeatButton, RadioButton, and ToggleButton </li></ul></ul><ul><ul><li>TextBox, ListBox, and DataGrid </li></ul></ul><ul><ul><li>TabControl, Slider, and MultiScaleImage </li></ul></ul><ul><ul><li>Border, Calendar, DatePicker, and more! </li></ul></ul><ul><li>Support styles, templates, and data binding </li></ul>
    24. 26. FrameworkElement ButtonBase ContentControl Control Button HyperlinkButton RepeatButton ToggleButton CheckBox RadioButton ScrollViewer Calendar DataGrid DatePicker GridSplitter TextBox RangeBase ItemsControl ListBox Slider Scrollbar TabControl
    25. 27. FrameworkElement Canvas Panel Grid StackPanel Border Image MediaElement MultiScaleImage TextBlock InkPresenter
    26. 28. <ul><li>Redefine a control’s entire visual tree </li></ul><ul><ul><li>Perform extreme customization without changing basic behavior of control </li></ul></ul><ul><ul><li>Exposed through control's Template property (inherited from Control base class) </li></ul></ul><ul><li>Use {TemplateBinding} to flow property values from control to template </li></ul><ul><li>Use ContentPresenter and ItemsPresenter to flow content and items to template </li></ul>
    27. 29. <ul><li>Styles provide level of indirection between visual properties and their values </li></ul><ul><ul><li>Define style as XAML resource </li></ul></ul><ul><ul><li>Apply style using {StaticResource} markup extension </li></ul></ul><ul><li>Can be scoped globally or locally </li></ul><ul><li>Combine styles and templates to “stylize” controls with custom visual trees </li></ul>
    28. 30. <ul><li>Permits properties of one object to be bound to properties of another </li></ul><ul><ul><li>Target property must be DependencyProperty </li></ul></ul><ul><ul><li>Source property can be any type of property </li></ul></ul><ul><ul><li>Source can be a collection if target supports binding to collections </li></ul></ul><ul><li>{Binding} markup extension provides declarative support for data binding </li></ul>
    29. 32. <ul><li>Added a ListBox control to our XAML </li></ul><ul><li>Applied a DataTemplate to the ListBox </li></ul><ul><li>Data-bound our new ListBox control to a generic list of user objects </li></ul><ul><li>Applied 2 different styles to our data-bound ListBox </li></ul>
    30. 33. <ul><li>System.Windows.Browser namespace contains classes for accessing browser DOM </li></ul><ul><ul><li>HtmlPage, HtmlWindow, and others </li></ul></ul><ul><li>Managed -> unmanaged </li></ul><ul><ul><li>Access DOM from managed code </li></ul></ul><ul><ul><li>Call JavaScript functions from managed code </li></ul></ul><ul><li>Unmanaged -> managed </li></ul><ul><ul><li>Call managed code from JavaScript </li></ul></ul><ul><ul><li>Process DOM events with managed code </li></ul></ul>
    31. 34. <ul><li>General-purpose file I/O not permitted </li></ul><ul><li>OpenFileDialog can be used to open files </li></ul><ul><ul><li>User interaction constitutes permission needed to safely open files </li></ul></ul><ul><ul><li>No SaveFileDialog yet </li></ul></ul><ul><li>Isolated storage can be used to persist data locally subject to quotas </li></ul><ul><ul><li>Quote is initially set to 1MB per domain but can be increased </li></ul></ul>
    32. 35. <ul><li>Silverlight 2 has rich networking support </li></ul><ul><ul><li>SOAP/XML Web services via WCF proxies </li></ul></ul><ul><ul><li>HTTP services (POX, REST, RSS, ATOM) via HttpWebRequest and WebClient classes </li></ul></ul><ul><ul><li>Socket support, asset downloads over HTTP, syndication classes, and more </li></ul></ul><ul><li>Cross-domain access supported using Flash-compatible or Silverlight XML policy files </li></ul>
    33. 36. <ul><li>Allowed if target domain has XML policy file in place permitting calls from other domains </li></ul><ul><ul><li>Crossdomain.xml – Requires domain=&quot;*&quot; allowing calls from any domain </li></ul></ul><ul><ul><li>Clientaccesspolicy.xml – Can restrict access to certain domains only </li></ul></ul><ul><li>Policy file must be located at domain root </li></ul>
    34. 37. <ul><li>Delegate-based HTTP networking API </li></ul><ul><ul><li>Supports asynchronous operation only </li></ul></ul><ul><li>Provides control over wire format </li></ul><ul><ul><li>GET/POST/PUT/DELETE (REST) </li></ul></ul><ul><ul><li>Customization of HTTP headers </li></ul></ul><ul><li>Completion methods called on background threads </li></ul>
    35. 38. <ul><li>Event-based HTTP networking API </li></ul><ul><ul><li>Commonly used to download assets </li></ul></ul><ul><ul><ul><li>DownloadStringAsync - String </li></ul></ul></ul><ul><ul><ul><li>OpenReadAsync – Stream (binary) </li></ul></ul></ul><ul><ul><li>Can also be used to perform uploads </li></ul></ul><ul><li>Fires progress and completion events and supports cancellation of pending requests </li></ul><ul><ul><li>Event handlers execute on UI thread </li></ul></ul>
    36. 40. <ul><li>Added a DataGrid control to our XAML </li></ul><ul><li>Opened and parsed a local XML file </li></ul><ul><li>Downloaded and parsed an RSS feed </li></ul><ul><li>Data-bound our parsed data to the added DataGrid control </li></ul>
    37. 41. <ul><li>Microsoft Silverlight is a cross-browser, cross-platform, and cross-device plug-in for delivering the next generation of media experiences and rich interactive applications for the Web </li></ul><ul><li>By using Expression Studio and Visual Studio, designers and developers can collaborate more effectively using the skills they have today to light up the Web of tomorrow </li></ul>
    38. 42. <ul><li>Visit the urls below for additional information </li></ul><ul><ul><li> </li></ul></ul><ul><ul><li> </li></ul></ul><ul><ul><li> </li></ul></ul>
    39. 43. For the latest titles, visit
    40. 44. These books can be found and purchased at all major book stores and online retailers
    41. 45. For training information and availability
    42. 46. 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. <ul><li>Step-by-Step training plans to build your development skills. </li></ul><ul><li>Premium technical content created by expert developers for developers. </li></ul><ul><li>Access to valuable online e-learning, e-references, and virtual labs. </li></ul><ul><li>50% discount on select certification exams and 30% discount on Microsoft Press training kits. </li></ul><ul><li>Join Ramp Up for free today! </li></ul><ul><li>Go to : </li></ul>
    43. 47. “ Looking at someone’s code, but with audio”
    44. 48. <ul><li>The nature of software development is radically changing ... </li></ul><ul><li>ARE YOU READY? </li></ul><ul><li>Prepare yourself for a demanding future. Attend the MSDN Developer Conference. </li></ul><ul><ul><ul><ul><li>Experience Microsoft’s Cloud Computing Platform </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Be among the first to see Windows 7 </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Take your .NET skills to the next level </li></ul></ul></ul></ul><ul><ul><ul><ul><li>The Cost? Just $99 </li></ul></ul></ul></ul><ul><li>To register, check out </li></ul><ul><li>RSVP Code: MDCDEV </li></ul><ul><li>Houston 12/9/08 Orlando 12/11/08 Atlanta 12/16/08 Chicago 1/13/09 Minneapolis 1/13/09 Washington, DC 1/16/09 New York 1/20/09 Boston 1/22/09 Detroit 1/22/09 Dallas 1/26/09 San Francisco 2/19/09 </li></ul><ul><li>ONILNE: Find our tag under #MSDNDevCon at Facebook, Twitter, Flickr, Delicious and Twemes </li></ul>
    45. 49. Dave Bost thank you!
    46. 50. © 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.