Developing Windows 8 Metro style applications that consume OData

Developing Windows 8 Metro style applications that consume OData

Rate This
  • Comments 11

The Source code for the sample app is available here ( Download )

You’ll need :
1. Windows 8 Consumer preview and developer tools
2. OData Client library preview for Windows 8 Metro ( Update: Visual Studio 2012 RC has been released and contains an updated version of these assemblies, along with fully-integrated support for Add Service Reference. Install the Ultimate, Professional, or Premium editions on Windows 8 Release Preview to get the update.) .

We’re releasing a preview version of the client libraries for Windows 8 Metro-Style applications to give our users
the ability to create applications that work on Windows 8 .   This client library will work with servers
that comply with the OData v1-v3 protocols. In the blog post below we will describe a sample application
we built and is available for download using this client library.

Step Zero is to generate the client types for the Netflix OData Service using the DataSvcUtil.exe tool.
We haven’t updated the “Add Service Reference”  gesture in Visual Studio 11 yet, so you’ll have to generate the client
types manually .

Here is how you generate the client proxy types for the Netflix OData Service

Open a command prompt as administrator and navigate to %windir%\Microsoft.NET\Framework\v4.0.30128

Run this command :

DataSvcutil.exe /uri:http://odata.netflix.com/Catalog/ /DataServiceCollection /Version:2.0
/out:netflixClientTypes.cs

Copy the generated netflixClientTypes.cs file into the application you create in the next step.

Open Visual Studio 11 > “Create new Project” >”Grid Application”

New_Metro_Grid_Project

 

“Genres” view

Genres

  

To build this view, we will add an “Items Page” and customize the Item template to display
details specific to the “Genre” type in the client types such as “Name”.
We further create a custom property called “TileTitle” which is the first title in the genre,
to see how this is implemented, please consult the ODataSampleViewModel.cs file.
When a user selects a “Genre” we will set the “SelectedGenre” property on the view model
and navigate to the “Titles” screen shown below.

 

“Titles In Genre” view.

Titles

To create this view, we will add another “Items Page” and customize the item template to display details specific to the “Title”
type in the generated client types. To load these titles, we track the selected Genre and call the “LoadTitlesForGenre”
method on the view model with the selected genre.
When a user selects a Title, we navigate to the “TitleDetails” view shown below, with the selected title as a navigation parameter.

“Title Details” view :

TitleDetail

To create this view, we add a “Basic page” and customize the layout to show the above content
from the selected title which is passed in as a navigation parameter.

Phani Raj,
Software Design Engineer 2,
OData / WCF Data Services

Leave a Comment
  • Please add 1 and 6 and type the answer here:
  • Post
  • Phani just published a blog post with directions on how to build OData apps for Windows 8 Metro. The

  • I did something similar in Windows 8 Metro using JavaScript here: codefoster.com/.../Simple-Netflix-Browser-in-Windows-8-JavaScriptndash;Part-1.aspx (Jeremy Foster @codefoster)

  • Trackback from SilverlightShow.net

  • In the previous post Running WCF Data Services on Windows 8 Consumer Preview- Part 1 , I described running

  • Fantastic article and long waited dll files. Thanks.

    I have one issue though. How do we send the credentials to OData service which uses forms authentication?

    I tried,  Context.Credentials = new NetworkCredential(uid, pwd);...

    Otherwise works fine.

  • I have the same problem as Young Oh. Sending credentials to WCF Data Service using the DataServiceContext.Credentials property doesn't seem to do anything.

  • Sorry! Just realized that it is included with the Visual Stuio 2012 RC and we don't have to deal with these stuff anymore.

  • The OData library seems to be broken with Windows 8 Release Preview and VisualStudio 2012 RC.

    I'm getting this exception:

    System.TypeInitializationException was unhandled by user code

     HResult=-2146233036

     Message=The type initializer for 'System.Data.Services.Client.TypeSystem' threw an exception.

     Source=Microsoft.Data.Services.Client.Metro

     TypeName=System.Data.Services.Client.TypeSystem

    Inner Exception:

    {"Could not load type 'System.Reflection.RuntimeExtensions.RuntimeReflectionExtensions' from assembly 'System.Reflection.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.":"System.Reflection.RuntimeExtensions.RuntimeReflectionExtensions"}

  • Please update to the Latest VS RC release to get the OData bits. The download published on this blog is no longer usable with the Windows 8 RC.

  • is there a simple way to port this demo to Win8 RC?  

  • octavp_2000,

    its not too difficult to get this sample to work on VS2012 RC and Win8 RC. You essentially need to use the Add Service Reference... functionality and remove the old definitions (i.e. netflixClientTypes.cs). You also have to fix-up some of the Fx changes such ApplicationViewState references and some style references that have changed since this sample was written. I did this in less than 20 minutes :)

Page 1 of 1 (11 items)