Quick-Start Primer Video to Windows Phone 7 Tools, Data Access and Notification Services

I recently did a 1-hour screencast interview with Carl Franklin for Dot Net Rocks TV.

It’s a good primer for a few areas of Windows Phone 7 developer.

20100720 video

If you are looking for in-depth rapid training on developing for Windows Phone 7 then you should consider registering for this first major boot camp running across Canada.

Windows Phone 7 Boot Camp

The recording was done using the April refresh of the tools.  I’ll be following up with another one soon using the Beta tools to explain things like themes and application life cycle in more detail.

We covered the tools…

20100720 tools

The emulator…

20100720 emulator

Project types…

20100720 project types

 

Visual Studio Tools…

20100720 vstools

Mapping Applications…

20100720 mapapp

Data Binding/Access… to a service exposed through Windows Azure AppFabric Service Bus

20100720 dataaccess

Notification Services which is essential to building applications that receive information from the cloud.

 

20100720 notification

Hopefully the video gives you a good sense of what is possible, and if you want this speed of knowledge transfer or faster… go for the bootcamp.

Windows Phone 7 Boot Camp

Develop Silverlight Applications for 20 Million Nokia Symbian Device Users

The Silverlight Runtime for Symbian Devices

Microsoft has released Symbian for Silverlight – a free download.

It supports Nokia S60 5th Edition devices such as:

  • Nokia 5800 XpressMusic
  • Nokia N97
  • Nokia N97 Mini
  • S60 5th Edition SDK 1.0 Emulator

Apparently this covers some 20 million users worldwide!  The version 7.2.xxx version of the WebKit based browser is recommended which will be in upcoming firmware updates.

The Tools

You’ll need the Windows-based Microsoft Silverlight for Symbian Developer Tools plus:

  • Visual Web Developer 2008 Express Edition with SP1 with Silverlight Tools for Visual Studio 2008 SP1
  • Visual Studio 2008 SP1 with Silverlight Tools for Visual Studio 2008 SP1
  • Expression Blend 2 SP1 (free trial version)

Other versions of Expression Blend and Visual Studio are not supported. Application deployment on Internet Information Services (IIS) or a comparable web server such as Apache is supported.

Only development with C# is support – not VB.

The Symbian-specific tools include:

  • Samples
  • Runtime for the emulator (and command line to install it); note that the documentation includes instructions on getting the emulator
  • Documentation

To test, you launch the emulator and browse to sites running the silverlight application you have built.  You can open .xap files in folders but then network calls will fail.  Not much debugging support – limited to some basic browser error notifications with some Nokia-specific modification – though you could debug in Visual Studio by running the application up in a desktop browser.

The Capabilities (or lack thereof)

The Silverlight runtime for supported Nokia devices is based on Silverlight 2 with some limitations, hence why VS 2008 and Blend 2 are the tools supported.

JavaScript is largely not supported.  Pure XAML is OK.  So it’s Silverlight 2 style XAML+.NET apps to go 🙂

The documentation details the media limitations but here are a few major points.

  • Media is played through the Nokia Nseries digital music player for A/V playback and progressive download.  Adaptive streaming requires IIS Smooth Streaming.
  • Video needs to be MP4 H.264 – Baseline Profile (with some specific limitations)
  • Audio needs to be MP4 AAC-LC (including HE-AAC)
  • Full-screen requires the MediaElement to be the only element sized to the screen.
  • OpenFileDialog is customized for the Nokia devices for finding/selecting media files, taking pictures, etc.

These media features are not supported:

  • HTTP traditional streaming

  • Server-side playlists

  • Client-side playlists

  • Built-in VCR controls

  • Multiple MediaElement controls in one plug-in

  • MediaElement control used as content within another Silverlight control

  • Markers

  • Video overlay

  • Transparency

  • Digital Rights Management (DRM)

  • Alpha blending

  • Rotation and skewing of videos (RotateTransform and SkewTransform)

  • Some members of MediaElement (see "MediaElement Support" later in this topic)

  • VideoBrush element

These Silverlight features/technologies are not supported:

  • Cryptography

  • Deep Zoom

  • Dynamic language runtime (DLR)

  • Digital Rights Management (DRM)

  • Expression trees

  • HTML DOM bridge

  • JavaScript programmability

  • LINQ to SQL

  • Localization of Silverlight resources

  • Reflection

  • Sockets

  • Visual Basic

  • Windows Communication Foundation (WCF)

A few other plug-in related features not supported:

  • ThreadPool

  • Multiple plug-ins on one page

  • Dynamic plug-in xap-file source

  • Silverlight plug-in object

  • Custom Request/Response Headers

  • Silverlight plug-in access from JavaScript

  • Updating HTML DOM Values Through Managed Code

  • No Timeout Error if Network Goes Down

The following Silverlight 2 technologies are supported. However, some features may not be supported, or behavior may be different because of platform differences.

  • Silverlight 2 class library – no VB, WCF, ADO.NET Data Services, JSON, various controls, Polling Duplex, Syndication Classes, XML Utils, Reflection, Sockets, etc…

  • Media – see above

  • Controls – no Silverlight SDK controls (just the runtime ones) plus no support for ComboBox or MultiScaleImage; some runtime controls may not be suitable for the devices

  • Input – support for min/full QWERTY on-screen keyboard, but no T9

  • Isolated storage – fixed at 1MB per application and user must manually remove files after cleanup with no UI provided; read only access flag not supported

  • Fonts – only device (TrueType) fonts available, but can embed fonts resources (if licensed of course)

  • Graphics – No VideoBrush

  • Networking – basically limited to HttpWebRequest and WebClient – check recommended use of Dispose for large downloads

You can view the Silverlight privacy policy here and try Bing and HSN Silverlight applications on your Nokia phone.

Silverlight Sample Application – Part 5

In this series blog post I’m completing this run about the sample Silverlight application that was used in the Ottawa and Toronto code camps this year.

You can get the source to the application on CodePlex.

The purpose of the application (other than to show people how to get started with Silverlight application development), was to be an IT event information application.  The fourth ‘page’ of the application shows a map of the area indicating the location of the event.

Here it is showing the location of the Ottawa IT Day event.

20100613 map

This was done using the Bing Maps Silverlight control.

There are 4 key resource links for using this control.

To use the control you:

  • Install the SDK (which will place a couple of important DLLs in a folder you specify when installing)
  • Add a reference to the SDK DLLs to your project.
  • Add the MapControl namespace to your page XAML

20100613 map ns

  • Add the control to your XAML

20100613 map xaml 

  • Setup the control how you link in your code behind file

20100613 map code

The ApplicationId is obtained from the developer portal where you’ll need to agree to various licensing conditions.  With the Id the control will show a message indicated that it needs to be licensed.

A specific ZoomLevel is set in this example and the view is set to road mode.

The Location is set up from properties on the Application class and initialised elsewhere in this case.

The map is centred on the desired location and a Pushpin added there too.

A piece of control tree is created in code and this is added to the map and positioned at the desired location.  See the interactive SDK to learn how to add information to the map.

This control is extremely powerful and can be seem working live in the Silverlight page designer inside Visual Studio, e.g. set the ZoomLevel as an attribute on the XAML map element and you’ll see the map zoom in live!

Quite straight forward and you can (as with any XAML-related coding) chose for the most party whether to place settings in XAML or in code.

My only real issue with the control is the licensing for use of the control on intranets.

This concludes the posts on the sample application.

Check out other series blog posts for previously posted information about this sample application.

Silverlight Sample Application – Part 4

In this series blog post I’m continuing to talk about the sample Silverlight application that was used in the Ottawa and Toronto code camps this year.

You can get the source to the application on CodePlex.

The purpose of the application (other than to show people how to get started with Silverlight application development), was to be an IT event information application.  The second ‘page’ of the application shows information on the tracks and sessions available.

Here it is showing session information for the Ottawa IT Day.

20100613 sessions

This data was published using an OData-based service which is included with the source code.

Silverlight 4 includes networking classes specifically for OData.  We can use the Add Service Reference feature to add proxy classes which in this case include EventDataContainer.

20100613 sessions code

Silverlight includes LINQ to OData client classes so we can create a LINQ query on the container client proxy class which will be translated (when enumerated) using the magic of IQueryable-based LINQ implementations into an OData URI.  We create a DataServiceCollection based on the Track proxy class and assign it to the ListBox so that results can be shown once this DataServiceCollection is populated.  We then set up a completion handler on the collection and then load the collection asynchronously which causes the LINQ query to be converted.

Once the query completes, we’ll have a set of Track objects in the collection that will appear bound in the UI.  For each Track object we then asynchronously load the Session information underneath each Track.

DataServiceCollection is great because it includes the INotifyCollectionChanged implementation that works with the Silverlight binding system to show the session information under each track as the data loads in.

Check out the code to see the bindings in the XAML.

Check out other series blog posts for more information about this sample application.

Silverlight Sample Application – Part 3

In this series blog post I’m continuing to talk about the sample Silverlight application that was used in the Ottawa and Toronto code camps this year.

You can get the source to the application on CodePlex.

The purpose of the application (other than to show people how to get started with Silverlight application development), was to be an IT event information application.  The third ‘page’ (yes – I’ll get to the second page in the next post) of the application shows tweets about the event.

Since the Ottawa and Toronto code camps happen in April and May, here’s the same page set up to show tweets tagged with #teched for this month’s Microsoft TechEd confeference.

20100613 tweets

To get the data, we can use one of the great methods available in Silverlight to get data – the WebClient class.  This class is often used when you are connecting to a RESTful service which is documented somewhere but is not self-described with metadata (like many SOAP/OData web service where Add Service Reference in Visual Studio can often be used to create a proxy class).

All network data access in Silveright must be asynchronous to avoid the UI from freezing up.

We create out WebClient, setup a completion event handler and start an asynchronous download of a string using the Twitter Search API.

20100613 tweet behind

Once the completion event fires, we make sure there’s no error and then pass off processing of the received string to a utility function to get back objects we can bind to on our ListBox.

The Twitter Search API response format is document (or discoverable at least) so we set up a class to hold the items of a tweet we are interested in, and use LINQ to XML code to pull out the appropriate XML elements from the Twitter API Atom feed.

 20100613 tweet util

It’s that simple when you get the hang of LINQ to XML.  It’s a must learn for the modern .NET developer.

With objects to bind to we need to create a DataTemplate for our ListBox ItemTemplate (the template used every time the visual tree for a new item needs to be generated).

20100613 tweet xaml

And there you have it.  It’s surprising there aren’t even more Twitter Clients coming out of the woodwork.

Check out other series blog posts for more information about this sample application.

Silverlight Sample Application – Part 2

In this series blog post I’m continuing to talk about the sample Silverlight application that was used in the Ottawa and Toronto code camps this year.

You can get the source to the application on CodePlex.

The purpose of the application (other than to show people how to get started with Silverlight application development), was to be an IT event information application.  The first ‘page’ of the application shows the event website.

20100613 home

To do this, our page simply includes the web browser control in the XAML…

20100613 webbrowser

and a bit of code in the code-behind class also inheriting from the provided Page class constructor.

20100613 webbrowser 2

Simple enough right?

Wrong.

This code will fail when you try to debug/launch the application in a web browser.  The web browser control requires the application to be installed out-of-browser by the user and with elevated full trust.

20100613 oob

In the project properties, running Out-of-Browser needs to be enabled, the settings configured and the “Require elevated trust when running outside the browser” needs to be checked.

So HTML content and be hosted alongside the Silverlight control in a web page, but to host HTML content inside the Silverlight control you need the user to agree to the elevated trust and run the application outside of the browser.

To avoid making this page useless when the application is run inside the web browser, code was added as follows:

20100613 oob detect

This code detects if the code is running out of browser or not.  If it’s in-browser then the browser control is hidden, and a hyperlink control added to the main grid allowing the user to click it and be taken to a web page using their default web browser.

Be sure to check out the other features a Silverlight 4 application can use if it runs out of browser.

Check out other series blog posts for more information about this sample application.

Silverlight Sample Application – Part 1

In this series blog post I’m starting a new set to talk about the sample Silverlight application that was used in the Ottawa and Toronto code camps this year.

I was given the whole Silverlight track to develop and lead in Ottawa and decided that I wanted to use the opportunity to show how a complete sample application can be built, deployed and adapted for Windows Phone 7.  At the same time I wanted to introduce many of the topics involved with Silverlight development.

Below is the chart showing the 5 sessions presented along with a section at the bottom showing a few other major topics we didn’t have time to include.

20100613 topics 

So, a fair challenge to pull off in 5 1-hour sessions.

This was made possible through the skills of my fellow track presenters: Peter Henry, Sylvain Boucher & Louis-Philippe Pinsonneault.  In particular Peter was my right-hand man and come up with the application concept.

I also repeated the Essentials and Data Matters sessions at the Toronto Code Camp.

You can get the source to the application on CodePlex.

In the next few posts I’m going to explain how parts of the application were built including use of the web browser control and out-of-browser applications…

20100613 home

using LINQ to XML to get data from Twitter…

20100613 tweets

connecting and Binding to OData…

20100613 sessions

and using the Bing Maps Silverlight Control…

 20100613 map  00

Overall the application leveraged the Silverlight Navigation Application project template for navigation.  The template is provided with the Silverlight Tools for Visual Studio.

So follow the series posts to learn how it was done.

In a later set of posts I’ll talk more about Silverlight data in more detail.

Silverlight From The Client To The Cloud: Part 5 – Image Data Binding

In this series final blog entry I’ll show how to enhance Silverlight binding to show image data as shown in a sample application I created that was demonstrated across Canada in Microsoft’s EnergizeIT tour.

20100514 claim

As I explained in Part 4 of this series, the data for the image above was downloaded from an ADO.NET Data Services (or an OData service) and displayed in the UI. 

Typically in Silverlight, an Image element has its Source set to the URL of an image and Silverlight takes care of downloading the image.

image

When the image needs to be dynamically set, you may not have a URL available (either different URLs or one that takes a query string parameter to dynamically return an image) to get the image you want.  Such a URL capability may be worth thinking about in the long run (given suitable security) using something like Windows Azure Storage (and its associated Content Delivery Network). 

What you may have is the bytes for the image returned to you through some data service request.

In that case you’ll need a binding convertor if you still want to use binding.

We create a class based on IValueConvertor which in this case can take the bytes and create the necessary BitmapImage as an acceptable source for the Image element.

image

We then need to use this in the XAML so we declare our class namespace in the XAML namespace…

image

then declare a resource instance based on the class, here called “converter”

image

then when we bind our image to the binary data stream, we use our converter…

 image

There are many uses for converters, typically converting between text and structured types, but this conversion between binary data and an image source is often useful and allows us to stay within a binding-based architecture.

This post concludes this series.

Silverlight From The Client to The Cloud: Part 4 – OData

In this series blog entry I’ll show that data from an ADO.NET Data Services (the OData predecessor) can be retrieved and displayed in a sample application I created that was demonstrated across Canada in Microsoft’s EnergizeIT tour.

Silverlight 3 includes support for consuming ADO.NET Data Services which use a RESTful architecture to expose CRUD operations on data in the cloud.

OData is a Microsoft-published open protocol which builds on ADO.NET Data Services.  Full OData support is not included in Silverlight 3, though a CTP add-on was made available.  Silverlight 4 does include support for consuming OData.

WCF Data Services in .NET 4.0 includes the ability to publish OData-based data sets based on entity framework models, CLR objects or a custom-built publisher.

OData (and its predecessor) is typically used for publishing and consuming sets of data, but in the sample application, we published sample insurance policy, claim data and customer activities using ADO.NET Data Services, and allowed client software to query the data for a single customer as shown here…

20100514 home

20100514 claim

In this case, not only was basic text data loaded into the UI, but binary image data was loaded into the application and geo-coordinates used with a Bing Maps Silverlight control to show a location.

In Silverlight 3 there are LINQ to ADO.NET Data Services classes and in Silverlight 4 (or the 3 add-on CTP) there are LINQ to OData client classes.

Code like the following allows Silverlight to easily connection to an OData service (after an earlier Add Service Reference) and query deeply into the datasets.

image

All such requests must be handled asynchronously in Silverlight, though inline anonymous delegates in C# (shown above) are very handy for processing the asynchronous results with inline code (though typically with more exception handling code than shown here).

Binding or imperative code (or MVVM) is then typically used to show the results in the UI.

This sample application represents a fairly basic case.  Silverlight 4 + OData opens up some great possibilities and you can see more in my Dot Net Rocks TV episode on how to create an OData services in .NET 4 WCF Data Services and consume it in Silverlight 4.

Silverlight From The Client to the Cloud: Part 3 – 3D UI Context

In this series blog entry I’ll explain how one can use perspective 3D in Silverlight 3+ to create interesting UI transitions as shown in the following screenshot sequence from part of a sample application I created that was demonstrated across Canada in Microsoft’s EnergizeIT tour.

Initial state prior to 3D animation…

20100514 home

the central UIElement is leant back and faded out in a short animation…

20100514 fade back

New UI is shown on top… using the energy reveal shown in Part 2 of this series….

20100514 claim

… and once this UI is removed, the UI behind is faded back in and pulled back up to its start position.

 

To do this means declaring a Projection property element on the component…

image

Property elements in XAML provide a means to declare a property that take an object rather than a simple value.  It would be difficult or clumsy to try to declare all the properties of an object (and even any sub objects) in a single attribute value.

We then need a storyboard to animate the X rotation of the projection on the UI element and the opacity of the UI element.

image

This has given you one possible use for the 3D projection addition in Silverlight 3.  Retaining elements of you UI on screen (but put ‘aside’ or back in this case) can help the user to easily keep track of their current context or position in the flow of the application UI navigation.