Silverlight development
for Windows Phone 7 CTP
Mike Taulty
Microsoft UK
mtaulty@microsoft.com
mtaulty.com
@mtaulty
Silverlight is...?
                                    4: line of business
                    3: out of browser
                                                     2010
2: .NET subset for RIA                  2009
                         2008
1: a media player

            2007
Silverlight is...?
                                    4: line of business
                    3: out of browser
                                                     2010
2: .NET subset for RIA                  2009
                         2008
1: a media player
                           a development platform
            2007           for Windows Phone 7
Silverlight development on the desktop
                                                       XAP


                     XAP


                      Manifest   Assembly   Resource
       C#

   Visual Basic

         XAML
                                                 Silverlight Fx/CLR
Silverlight development on Windows Phone 7

                                                Windows Phone
                                                 Marketplace
                    XAP


                     Manifest   Assembly   Resource
       C#

   Visual Basic

         XAML
                                                .NET Compact
                                               Framework/CLR
demo
“Hello World” on the phone
Silverlight functionality on Windows Phone 7



  a   super-subset TM     of Silverlight 3
Silverlight 3 functionality on the desktop
                    UI Capabilities                      Network
                                                         •   HTTP(S)
   Graphics              Media                Controls   •   WCF HTTP(S)
                                                         •   WCF Data Services
                                                         •   Sockets

                                                         Browser
                                                         • HTML Interop
                                                         • Javascript Interop
                                                         • SL  SL Local Messaging
         Composition, Layout, Styling, Resources,        File System
     Animation, Data Binding, Transformations, Effects
                                                         • File Access
                                                         • Isolated Storage
Silverlight 3 functionality on the desktop
Core Assemblies                       SDK Assemblies
   Browser Interop   Core UI          Controls                  WCF
                     • Controls
                                      •   DataGrid              • Data Services
    Serialization    • Media
                                      •   DescriptionViewer     • PollingDuplex
                     • Shapes
                                      •   Label                 • Syndication
     Networking      • etc
                                      •   ValidationSummary
                                      •   Calendar                Data Annotations
                     Core Framework
  WCF ServiceModel                    •   DatePicker
                     • Collections    •   GridSplitter                  JSON
                     • IO             •   TabControl
        XML
                     • Diagnostics                                   LINQ to XML
                                      •   TreeView
                     • Reflection
     Visual Basic                     •   AutoCompleteBox
                     • Threading                                  XML Serialization
                                      •   PagedCollectionView
                     • etc.
Silverlight 3 functionality in the Phone CTP
Core Assemblies                       SDK Assemblies
   Browser Interop   Core UI          Controls                  WCF
                     • Controls
                                      •   DataGrid              • Data Services
    Serialization    • Media
                                      •   DescriptionViewer     • PollingDuplex
                     • Shapes
                                      •   Label                 • Syndication
     Networking      • etc
                                      •   ValidationSummary
                                      •   Calendar                Data Annotations
                     Core Framework
  WCF ServiceModel                    •   DatePicker
                     • Collections    •   GridSplitter                  JSON
                     • IO             •   TabControl
        XML
                     • Diagnostics                                   LINQ to XML
                                      •   TreeView
                     • Reflection
     Visual Basic                     •   AutoCompleteBox
                     • Threading                                  XML Serialization
                                      •   PagedCollectionView
                     • etc.
Silverlight 3 functionality in the Phone CTP
                    UI Capabilities                      Network
   Graphics              Media                Controls   • HTTP(S)
                                                         • WCF HTTP(S)
                                                         File System
                                                         • Isolated Storage

                                                             Phone
         Composition, Layout, Styling, Resources,
     Animation, Data Binding, Transformations, Effects      Specific
                                                          Functionality
about
the phone...
application structure – navigation applications
   desktop Silverlight         phone Silverlight
        RootVisual                 RootVisual

       UserControl            PhoneApplicationFrame

         Content              PhoneApplicationPage

               Frame

                     Page
application lifecycle     app may be
                                                    Not
                          terminated              Running

              Shell
           Switch Apps
           Notification
                                          Exit              Startup




                              Paused              Running




                                       Obscured
controls and themes
    standard Silverlight controls re-themed

 wide margin for
 ease of touch


    support for dynamic theming based on
    user settings
demo
navigation & control theming
physical information about the phone

                                where is the phone?

  screen resolution?
                                    can I alert the user?

  screen orientation?
                                  is the phone moving?
where is the phone?
 GeoCoordinateWatcher watcher =
   new GeoCoordinateWatcher(GeoPositionAccuracy.Low); // saves power

 watcher.MovementThreshold = 20; // minimum of 20m - avoids noise, saves power

 watcher.StatusChanged += (sender, args) =>
 {
    if (args.Status == GeoPositionStatus.Ready) { // ready... }
 };

 watcher.PositionChanged += (sender, args) =>
 {
    double altitude = args.Position.Location.Altitude;
    double latitude = args.Position.Location.Latitude;
    double longitude = args.Position.Location.Longitude;
 };

 watcher.Start(); // this can throw and we should call Stop()     System.Device.Location.dll
where is that again?
 CivicAddressResolver resolver = new CivicAddressResolver();
 GeoCoordinate location = GetAlreadyDeterminedLocation();

 resolver.ResolveAddressCompleted += (sender, args) =>
 {
   if (args.Error == null)
   {
     string line1 = args.Address.AddressLine1;
     string line2 = args.Address.AddressLine2;
     string city = args.Address.City;
     // etc...
   }
 };

 resolver.ResolveAddressAsync(location);                 System.Device.Location.dll
is the phone moving? can I alert the user?
 AccelerometerSensor.Default.ReadingChanged += (sender, args) =>
 {
   if (args.Value.State == SensorState.Ready)
   {
     // Deltas X,Y,Z from -1 to +1 – should also check timestamp here
     if (args.Value.Value.Y >= -0.5)
     {
       // Help! I'm falling! Not sure this will help but...
       VibrateController.Default.Start(new TimeSpan(0, 0, 2));
     }
   }
 };
                                                         Microsoft.Devices.dll
 // this could throw & we should stop it at some point
 AccelerometerSensor.Default.Start();                        Microsoft.Devices.Sensors.dll
demo
physical aspects of the phone
input capabilities of the phone
                                     multi-touch

    soft
 input panel




 hardware buttons                 ApplicationBar
demo
input capabilities
reaching out to existing phone functionality
      Choosers                     Launchers
   Launchers
     • EmailAddressChooserTask    • BingMapsTask
      “fire and forget” an OS app• CameraCaptureTask
      • PhoneNumberChooserTask
      • PhotoChooserTask          • EmailComposeTask
   Choosers                       • MarketplaceLauncher
                                  • MediaPlayerLauncher
      OS offers selection UI for app
                                  • PhoneCallTask
   WebBrowser control for HTML integration
                                  • SaveEmailAddressTask
                                  • SavePhoneNumberTask
                                  • SearchTask
                                  • SMSComposeTask
                                  • WebBrowserTask
demo
launchers, choosers, web browser
reaching out to the cloud for notifications
                        request
                        unique URI          Cloud Service


         MyApp
                            URI
                                                      HTTP POST
                 transmission
                 of this URI is            Service (or Client)
                 “out of band”       URI
                                            with push data
reaching out to the cloud for notifications

                                                        Cloud Service


         MyApp

                                                                  HTTP POST
            notification types
            •    raw – only to a foreground app
            •    toast – foreground app or as a
                 toast if app is not foreground
            •    tile – always to the tile & also to
                                                       Service (or Client)
                 the app if in the foreground           with push data
demo
push notifications
reaching out to XNA functionality

   XNA libraries offer additional functionality
      e.g. audio capture from phone’s microphone




   covered in Paul’s talk next...
resources
   developer.windowsphone.com
     Charles Petzold Preview Book
   learningwindowsphone.com
     Sample Chapters from O’Reilly Book
   channel9.msdn.com
     Windows Phone 7 Training Kit
   odata library for Windows Phone 7 CTP
   silverlight.net
© 2010 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.

Mike Taulty TechDays 2010 Silverlight and Windows Phone 7 CTP

  • 2.
    Silverlight development for WindowsPhone 7 CTP Mike Taulty Microsoft UK mtaulty@microsoft.com mtaulty.com @mtaulty
  • 3.
    Silverlight is...? 4: line of business 3: out of browser 2010 2: .NET subset for RIA 2009 2008 1: a media player 2007
  • 4.
    Silverlight is...? 4: line of business 3: out of browser 2010 2: .NET subset for RIA 2009 2008 1: a media player a development platform 2007 for Windows Phone 7
  • 5.
    Silverlight development onthe desktop XAP XAP Manifest Assembly Resource C# Visual Basic XAML Silverlight Fx/CLR
  • 6.
    Silverlight development onWindows Phone 7 Windows Phone Marketplace XAP Manifest Assembly Resource C# Visual Basic XAML .NET Compact Framework/CLR
  • 7.
  • 8.
    Silverlight functionality onWindows Phone 7 a super-subset TM of Silverlight 3
  • 9.
    Silverlight 3 functionalityon the desktop UI Capabilities Network • HTTP(S) Graphics Media Controls • WCF HTTP(S) • WCF Data Services • Sockets Browser • HTML Interop • Javascript Interop • SL  SL Local Messaging Composition, Layout, Styling, Resources, File System Animation, Data Binding, Transformations, Effects • File Access • Isolated Storage
  • 10.
    Silverlight 3 functionalityon the desktop Core Assemblies SDK Assemblies Browser Interop Core UI Controls WCF • Controls • DataGrid • Data Services Serialization • Media • DescriptionViewer • PollingDuplex • Shapes • Label • Syndication Networking • etc • ValidationSummary • Calendar Data Annotations Core Framework WCF ServiceModel • DatePicker • Collections • GridSplitter JSON • IO • TabControl XML • Diagnostics LINQ to XML • TreeView • Reflection Visual Basic • AutoCompleteBox • Threading XML Serialization • PagedCollectionView • etc.
  • 11.
    Silverlight 3 functionalityin the Phone CTP Core Assemblies SDK Assemblies Browser Interop Core UI Controls WCF • Controls • DataGrid • Data Services Serialization • Media • DescriptionViewer • PollingDuplex • Shapes • Label • Syndication Networking • etc • ValidationSummary • Calendar Data Annotations Core Framework WCF ServiceModel • DatePicker • Collections • GridSplitter JSON • IO • TabControl XML • Diagnostics LINQ to XML • TreeView • Reflection Visual Basic • AutoCompleteBox • Threading XML Serialization • PagedCollectionView • etc.
  • 12.
    Silverlight 3 functionalityin the Phone CTP UI Capabilities Network Graphics Media Controls • HTTP(S) • WCF HTTP(S) File System • Isolated Storage Phone Composition, Layout, Styling, Resources, Animation, Data Binding, Transformations, Effects Specific Functionality
  • 13.
  • 14.
    application structure –navigation applications desktop Silverlight phone Silverlight RootVisual RootVisual UserControl PhoneApplicationFrame Content PhoneApplicationPage Frame Page
  • 15.
    application lifecycle app may be Not terminated Running Shell Switch Apps Notification Exit Startup Paused Running Obscured
  • 16.
    controls and themes standard Silverlight controls re-themed wide margin for ease of touch support for dynamic theming based on user settings
  • 17.
  • 18.
    physical information aboutthe phone where is the phone? screen resolution? can I alert the user? screen orientation? is the phone moving?
  • 19.
    where is thephone? GeoCoordinateWatcher watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Low); // saves power watcher.MovementThreshold = 20; // minimum of 20m - avoids noise, saves power watcher.StatusChanged += (sender, args) => { if (args.Status == GeoPositionStatus.Ready) { // ready... } }; watcher.PositionChanged += (sender, args) => { double altitude = args.Position.Location.Altitude; double latitude = args.Position.Location.Latitude; double longitude = args.Position.Location.Longitude; }; watcher.Start(); // this can throw and we should call Stop() System.Device.Location.dll
  • 20.
    where is thatagain? CivicAddressResolver resolver = new CivicAddressResolver(); GeoCoordinate location = GetAlreadyDeterminedLocation(); resolver.ResolveAddressCompleted += (sender, args) => { if (args.Error == null) { string line1 = args.Address.AddressLine1; string line2 = args.Address.AddressLine2; string city = args.Address.City; // etc... } }; resolver.ResolveAddressAsync(location); System.Device.Location.dll
  • 21.
    is the phonemoving? can I alert the user? AccelerometerSensor.Default.ReadingChanged += (sender, args) => { if (args.Value.State == SensorState.Ready) { // Deltas X,Y,Z from -1 to +1 – should also check timestamp here if (args.Value.Value.Y >= -0.5) { // Help! I'm falling! Not sure this will help but... VibrateController.Default.Start(new TimeSpan(0, 0, 2)); } } }; Microsoft.Devices.dll // this could throw & we should stop it at some point AccelerometerSensor.Default.Start(); Microsoft.Devices.Sensors.dll
  • 22.
  • 23.
    input capabilities ofthe phone multi-touch soft input panel hardware buttons ApplicationBar
  • 24.
  • 25.
    reaching out toexisting phone functionality Choosers Launchers Launchers • EmailAddressChooserTask • BingMapsTask “fire and forget” an OS app• CameraCaptureTask • PhoneNumberChooserTask • PhotoChooserTask • EmailComposeTask Choosers • MarketplaceLauncher • MediaPlayerLauncher OS offers selection UI for app • PhoneCallTask WebBrowser control for HTML integration • SaveEmailAddressTask • SavePhoneNumberTask • SearchTask • SMSComposeTask • WebBrowserTask
  • 26.
  • 27.
    reaching out tothe cloud for notifications request unique URI Cloud Service MyApp URI HTTP POST transmission of this URI is Service (or Client) “out of band” URI with push data
  • 28.
    reaching out tothe cloud for notifications Cloud Service MyApp HTTP POST notification types • raw – only to a foreground app • toast – foreground app or as a toast if app is not foreground • tile – always to the tile & also to Service (or Client) the app if in the foreground with push data
  • 29.
  • 30.
    reaching out toXNA functionality XNA libraries offer additional functionality e.g. audio capture from phone’s microphone covered in Paul’s talk next...
  • 31.
    resources developer.windowsphone.com Charles Petzold Preview Book learningwindowsphone.com Sample Chapters from O’Reilly Book channel9.msdn.com Windows Phone 7 Training Kit odata library for Windows Phone 7 CTP silverlight.net
  • 32.
    © 2010 MicrosoftCorporation. 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.