Inside Windows Phone (HD) - Channel 9

de Microsoft

Episodios

Developer Evidence: Carmella Ryen Macababbad's Password Protector

por Microsoft

Carmella Ryen Macababbad designed and developed the Password Protector app for the military to efficiently meet the secure access guidelines of the organization and empower the personnel with an easy-to-use app. She talks about her approach and Windows 8.1 in this video.

IWP77: Leveraging Social Extensibility in Windows Phone Silverlight 8.1 apps

por Microsoft

In Windows Phone 8.1 we delivered broader developer integration endpoints in the operating system. Developers can now deliver applications that plug into several aspects of the People Hub.

In this short video, Cliff and I walked through the three new specific extensibility points. Here are some links for more detail:

Cliff's blog on Social Extensibility in Windows Phone 8.1

Official Documentation on Social Extensibility in Windows Phone:

Jeff Wilcox's source for a stub application to register an existing app as a Me card integration target (github)

Please let us know if you have any questions!

LL @larryalieberman

IWP76: Matt Hidinger on Live Tiles in Windows 8.1

por Microsoft

This week we've got Matt Hidinger, Program Manager for the Live Tile Platform on Windows, to chat with us about the new features of Live Tiles in Windows and Windows Phone, and What Developers Need To Know (TM).

Here are some related resources you may be interested in:

Matt's talk from Build 2014

Tile Template Catalog

Great Official Live Tile Samples from Microsoft: (1) App Tiles and Badges, (2) Secondary Tiles, (3) Periodic Background Agent for Tiles and Toasts, (4) Pinned Site

Comprehensive overview of Tiles, Notifications, and Action Center in Windows Phone, from the Windows Phone 8.1 Jumpstart Training.

Please let us know if you have any questions!

LL @larryalieberman

IWP75: Tim Heuer on Windows Runtime XAML

por Microsoft

This week, Lead Program Manager Tim Heuer joined us to talk about all the announcements from Build 2014 with regard to Windows Runtime XAML, (as well as the unified Windows platform in general)

As you more than likely know, XAML is the specific schema of XML leveraged by several different Microsoft programming languages and frameworks for declaratively creating user experiences.

Tim was behind an enormous amount of work that took place to drive this release of the universal XAML for Windows Runtime framework in this last release of Windows Phone, (8.1), as well as the current version of Windows (8.1 update) for PCs, laptops and tablets. In this interview, he walks us through an awesome demo he prepared for the Build 2014 keynote that presents exactly how to utilize Windows Runtime XAML to deliver a compelling experience across device types, using universal projects in Visual Studio 2013 update 2, (the release candidate unveiled at Build).

Here are some links to related materials for more information.

Please let me know if you have any feedback!

LL @larryalieberman

IWP74: Thomas Fennel on the Windows Notification Platform

por Microsoft

The most compelling mobile applications take advantage of notification services in order to dynamically update based on external criteria. On Windows Phone, Live Tiles are perhaps one of the most distinct features that drive app adoption, so its critical to understand these how these services work, and how you can use them to drive these dynamic experiences.

Thomas took time from his extremely busy schedule to walk through some of the most exciting new aspects of the Windows Notification Platform that were announced at Build this month, and demonstrate some of the newly supported developer scenarios.

Here are some links to relevant related material touched on in the conversation:

Additionally: if you are currently working on an app for Windows, make sure and check out our //Publish events coming up in May, to over 60 cities world wide. These are sort of like hackathons, however, you bring your in-progress code, and windows development experts are on hand to help you polish your app and get it as good as possible for publication. For those who submit their apps for publication and register by June 1st, there are opportunities to win all sorts of cool prizes. Check out all the details at http://publishwindows.com!

Let us know if you have any feedback!

Larry Lieberman @larryalieberman

IWP73: Peter Torr on Targeting Multiple Resolutions

por Microsoft

At Build 2014 we announced the ability to build universal app projects in Visual Studio that can be leveraged to easily deliver apps for both Windows Phone and Windows PC/Laptop/Tablet. This new offering makes it easier than ever to share your business logic, and also does a few interesting things to help you with tailoring your UI as well... but there is still more you might want to do to maximize your users' experience in your application.

Peter Torr gave a great talk about this topic at Build 2014, where he asserted, "we shouldn't be talking about DPI or resolution anymore, but rather about _effective_ resolution". Today we met with Peter to get more detail on what he meant by that, as well as his advice on some basic techniques that *you* can use to easily deliver form factor optimized applications from a single code base.

Now, layout rules like this don't ship "in the box" at this point, but Peter's put together a great sample that demonstrates exactly how you could build out layout rules that could be wired to Visual States in order to achieve this automatic re-layout behavior based on the exact viewable space available to the app, regardless of the specific device the user is using.

Here are some links to related material:

Please let us know if you have any questions!

Larry Lieberman @larryalieberman

IWP72 | Deploying Windows Phone apps for the Enterprise

por Microsoft

This week we talked about publishing applications for Windows Phone for the Enterprise. There are a few different possibilities to start distributing your applications to your users. In the video we talked about three different possibilities:

  1. Through the store

  2. As a beta

  3. Private distribution

Through the store

When distributing application through the store the process is exactly the same as apps for consumers. You build your app and submit it so Microsoft can certify the application. If you access corporate data you need to make sure Microsoft has access to a test account which they need to validate the application. Testing is the same as any other application and you need to fulfill all store policies.

You can choose to publish the application hidden so it can only be installed when users have the deep link to the app. Best practice is to secure your corporate data with an login because when other people get access to the deeplink they can all install the application.

Beta apps

The 2nd way is to distribute the application as a beta app in the store. You need to provide all live id of your users and send them the link to the store. The advantage of beta is they don't expire anymore. If you want to remove access to the application for your users you need to build in a mechanism yourself. You can't force the apps to be removed from the phone once the users have the app installed. The check if the user is allowed to the beta is only performed during install

Private distribution

The last option is to side load applications. This can be done through an MDM solution like intune or you can sideload apps through email or website. Let's get into a little bit more detail how you can privately distribute your applications.

First step is you need to create a developer account at http://dev.windowsphone.com/. You need to make sure you create a company account and not an individual developer account. Part of this process is Microsoft asks for some proof if you are really the company you tell us you are.

Once you have created this developer account you can buy an Enterprise Mobile Signing Certificate from Symantec. Currently we only support Symantec certificates to sign your corporate Windows Phone applications.

Generic Episode Image

When you request the certificate from Symantec you have to copy the Symantec Id from the screen above.

Generic Episode Image

Once you have paid Symantec they also do some validations and they will create the certificate for you. Make sure you request and download the certificate from the same machine. The certificate is valid for 1 year.

Once you have the certificate you can use this to create a so called Application Enrollment token (or AET). This token needs to be distributed to the phones before they can run applications signed with the Symantec certificate.

When you have installed the Windows Phone SDK there are also a few tools installed which helps you sign your applications and create the AET. The following command creates the Application Enrollment Token:

"c:\program files (X86)\Microsoft SDKs\Windows Phone\v8.0\Tools\AETGenerator\AETGenerator.exe" "c:\temp\cert.pfx password"

When you run this tool the AET.xml, AET.aet and the AET.aetx files are generated. The .aetx file needs to be distributed to the phones. This file is an XML file which contains the publisher ID which is signed by the certificate and is used every time the phone tries to start a side loaded app.

You can sent the AETX file through email or a (secure) website to your users or use an MDM environment to automatically distribute this file once they enroll in your corporate environment. InTune for example generates this file automatically for you when you upload the certificate to the management environment.

The Application Enrollment token is valid for a year. After a year you need to renew the token on every device.

Running side loaded apps on your phone

Every time you start a side loaded application on your phone the Execution Manager extracts the publisher id from the signed application. This is used to find the associated AET. The AET must be present and valid (not expired, revoked or disabled). If the AET is still valid the application is launched. So when you replace the AET with a new one it still contains the same publisher id and the applications will still launch.

When you install an application this check is performed as well, the extra check which is performed at install time is if application is signed with a valid certificate. This means when you renew your certificate you need to resign your apps, otherwise people are not able to install the apps. Applications installed on your phone will still work as long as the AET is valid.

Phone Home

Every 24 hours the phone tries to connect with the Microsoft Servers to validate its Enterprise Application Token. The phone sends the device ID, publisher ID's and enterprise app ID's to the server. The servers check if the publisher ID is revoked or not. If the ID is revoked applications of that enterprise are blocked from being installed or launched.

This is checked every 24 hours or every time a phone is enrolled or an application is installed.

If the phone cannot phone home after 7 consecutive attempts the install of enterprise apps is blocked, but installed applications can still be launched. This covers the scenario where users are working offline or without internet connectivity for an extended period of time. If the phone cannot phone home for over 30 days the applications are blocked from launching.

The following figure shows the data which is send to the Microsoft servers.

Generic Episode Image

And this is the response Microsoft returns:

Generic Episode Image

Signing your applications

Before you can distribute your apps you need to sign them with the certificate bought from Symantec. The following command line can be used to sign the apps (the tools are installed with the Windows Phone SDK)

XapSigntool.exe sign /SignTool "c:\Program Files (x86)\Windows Kits\8.0\binX86" /f "c:\temo\certificate.pfx" /p password "c:\temp\application.xap"

Some MDM providers can sign the application for you, so you only need to upload the XAP file to their system and they will take care of it.

Differences

So let's summarize the differences between public and private distribution.

Managed

You need to purchase an MDM solution. But you will have automatic Application Enterprise token distribution and renewals. You will have full MDM management capabilities like the different policies available. You can un-enroll devices. You can only enroll to one MDM system at a time. You can automatically update apps and you will get a built-in private app inventory.

Unmanaged

You need to distribute your apps through an Intranet server or email. You have to manually distribute the AET. You can only un-enroll a phone by a full phone reset. You can enroll to multiple companies simultaneously, applications need to be updated manually and there is no automatic private app inventory.

Conclusion

There are a few different ways to distribute your enterprise applications to your employees. The managed approach through an MDM environment gives you the most flexibility. Also distributing your applications through the store is still a possibility as long if you provide Microsoft some test credentials. Building applications is the same as regular consumer apps so start building your enterprise applications for Windows Phone.

Resources

Windows Phone For Business

Company App Distribution for Windows Phone

 

 

 

 

IWP71 | NoSQL

por Microsoft

This week we are meeting again with our big friend Rob Tiffany. This time we talk about NoSQL. It's an easy way to store your data offline on your phone. During this conversation Rob explains what NoSQL is, why you would use it and what the challenges are.

Below are the code samples how to perform the CRUD operations on your in memory classes.

Define Table schema (Entity)

publicsealedclassCustomer
{
    publicint CustomerId { get; set; }
    publicstring FirstName { get; set; }
    publicstring LastName { get; set; }
}

Define Table (Generic List to hold collection of Customer objects)

publicstaticList<Customer> Customers { get; set; }

Create Table

Customers = newList<Customer>();

Save Table

publicstaticasyncTask SaveChanges<T>(T collection, String tableName)
{
    var file = awaitApplicationData.Current.LocalFolder.CreateFileAsync(tableName, CreationCollisionOption.ReplaceExisting);
    var outStream = await file.OpenStreamForWriteAsync();
    var serializer = newDataContractJsonSerializer(typeof(T));
    serializer.WriteObject(outStream, collection);
    await outStream.FlushAsync();
    outStream.Dispose();
}

Calling the Save Table Method

await SaveChanges<List<Customer>>(Customers, "Customer");

Load Table

publicstaticasyncTask<T> LoadTable<T>(string tableName)
{
    StorageFile file = awaitApplicationData.Current.LocalFolder.GetFileAsync(tableName);
    Stream stream = await file.OpenStreamForReadAsync();
    DataContractJsonSerializer serializer = newDataContractJsonSerializer(typeof(T));
    T table = (T)serializer.ReadObject(stream);
    stream.Dispose();
    return table;
}

Calling the Load Table Method

Customers = await LoadTable<List<Customer>>("Customer");

Insert Customers

Customers.Add(newCustomer
{
    CustomerId = 1,
    FirstName = "Andy",
    LastName = "Wigley"
});

Update Customers

foreach (var item in Customers.Where((c) => c.CustomerId == 2))
{
    item.FirstName = "Mike";
}

Delete Customers 

Customers.RemoveAll((c) => c.CustomerId == 2);

Select Customers

var query = from c inTableService.Customers
            select c;
 
CustomersList.ItemsSource = query.ToList();

Tweet to @robtiffany or @mahoekst

IWP70 | Mobile Enterprise Application Platform

por Microsoft

This we week we meet again with Rob Tiffany. This time we talk about MEAP. We discussed what a Mobile Enterprise Application Platform consists off and how it maps to Microsoft products.

As always, when you want to get started on Windows Phone in the Enterprise the Windows for Business is the right place to start.

Rob wrote some interesting articles on his blog about MEAP

We did talk about a lot of different technologies in a few different products.

Some other interesting related content from Tech Ed North America 2014

From the official developer documentation

 Tweet to @robtiffany or @mahoekst

 

 

IWP69 | Enterprise Mobile Management

por Microsoft

Today we were joined by Rob Tiffany, who gave us the overview of what Mobile Management in the Enterprise means.

First a shout-out to the Hour of Code we mentioned in our video.

We talked about EMM, MDM, MAM, MIM and MCM.

EMM

Here are links to some resources that go more in depth on the topics we discussed. Please let us know if you have any questions or comments!

The Windows Phone for "Business" page

Microsoft Mobility Management (EMM) is Here blog post from Rob Tiffany

From Tech Ed North America 2014

From the official developer documentation

 Tweet to @robtiffany or @mahoekst

 

 

IWP 68 | Unity & Windows Porting labs (2/2): advice on how to become a game developer

por Microsoft

At the end of August 2013, we gathered a crew of technical experts and headed to the Unity Unite 2013 event in Vancouver, British Columbia, where we worked hands-on with developers for three days in our Porting Lab.

By the end of the lab, we had helped developers port about 80 apps from iOS, Android, and other platforms to Windows Phone or Windows Store.

We asked with several developers to give some advice on how to become a game developers.

In this video you'll hear what advice they give on how to become a game developers.

Interviewees are:

Additional links:

IPW67 | Unity & Windows Porting labs (1/2): feedback on porting experience from developers

por Microsoft

At the end of August 2013, we gathered a crew of technical experts and headed to the Unity Unite 2013 event in Vancouver, British Columbia, where we worked hands-on with developers for three days in our Porting Lab.

By the end of the lab, we had helped developers port about 80 apps from iOS, Android, and other platforms to Windows Phone or Windows Store. We spoke with several developers attending Unite about their porting experience.

In this video you'll hear what they had to say about their porting experience.

Interviewees are:

 

Additional links:

IWP66: Windows Phone for Enterprise Developers

por Microsoft

Today we were joined by Matthijs Hoekstra, who gave us the lowdown with regard to how Windows Phone meets the needs of the enterprise developer.

Here are links to some resources that go more in depth on the topics we discussed. Please let us know if you have any questions or comments!

The Windows Phone for "Business" page

From Tech Ed North America 2014

From the official developer documentation

 Tweet to @LarryALieberman or @mahoekst

X

IWP65 | Localization Made Easy with Multilingual App Tookit

por Microsoft

Download the Multilingual App Toolkit for Windows and Windows Phone.

One of the exciting things about Windows Phone development is the extraordinary reach that Windows Phone apps have across the world. Windows Phone apps can be made available in 191 markets across the world and we've seen great adoption of Windows Phone in many different languages. In fact, the Windows Phone app market in China is bigger than it is in the US.

This means that for Windows Phone developers to reach the largest possible audience for their application, they need to adopt some localization best practices. This is where the Multilingual App Toolkit (MAT) comes in.

Using MAT, developers can access machine translation through the Microsoft Language Portal for their application resources at absolutely no cost. If you prefer a different source for machine translation, MAT allows support for 3rd part translation providers.

For scenarios where you might prefer human translation (or translation verification), MAT has the ability to import and export multiple XLIFF files.   

Watch the video for all the details and make sure you utilize the power of the Multilingual App Toolkit when you're looking to expand the market for your application.

Additional Resources:

Introduction to the Multilingual App Toolkit

Build multi-language apps using the Multilingual App Toolkit

Test multi-language apps using the Multilingual App Toolkit

Localize multi-language apps using the Multilingual App Toolkit

Submitting your localized app to the Windows Store

 

IWP 64 | Rate My App

por Microsoft

Today we talked about a tactic you can use to help you maintain a closer relationship to the people using your app, as well as help you get ratings and reviews. Nokia's recently released an excellent code sample that makes it easier than ever to subtly prompt your user on a periodic basis, to rate your application. We took a quick look at how easy it is to add the control to an existing application, and also talked a little bit about the Nokia DVLUP site.

Here are some detail on the items we discussed:

Please let us know any questions you may have, or feedback.

Tweet to @LarryALieberman or @matthiasshap

IWP63 | Easily Adding Auth and Push to your WP App with Windows Azure Mobile Services

por Microsoft

This week, Matthias gave us a quick introduction to Windows Azure Mobile Services (WAMS) for Windows Phone Developers.

Lots of folks we talk to find the prospect of building a server component to their Windows Phone app a bit daunting, but Azure Mobile Services opens up a whole new universe of possibilities in terms of the experiences you deliver to your customers: Data Storage, Authentication, and Push Notifications.

In this video, Matthias provides some more depth on adding Authentication and Push Notifications for Windows Phone apps. In many ways, this is an extension of the demo that Nick Harris performed in the video Windows Phone - Getting Started With Windows Azure Mobile Services.

Here are some additional places to go to get more information 

Questions? Tweet to @matthiasshap

IWP62: A Common HTTP stack for Windows & Windows Phone

por Microsoft

In IWP61: Building for Windows Phone and Windows 8 - The Basics, Matthias Shapiro and Matt Hidinger talked about how to build apps for both Windows Phone and for Windows 8, how to use an architecture that allows the developer to share as much code as possible between them.

In this edition, Andy Wigley and Mike Taulty from Microsoft UK dig deeper into one particular area: writing shareable HTTP networking code using the HttpClient API. HttpClient is a new API originally released for Windows 8 Store apps and .NET Framework 4.5, but is not included in the Windows Phone 8 SDK. This and other differences in the networking APIs for Windows Phone SDK and the Windows 8 (Windows Store Apps) SDK makes writing shareable code for HTTP networking challenging. However, the .NET Framework Base Class Libraries team recently released a portable implementation of HttpClient that works on Windows Phone 7.1 and above, .NET Framework 4.0 and higher, Silverlight and Windows 8 Store Apps.

Andy walks through the basics of programming with HttpClient including how to take advantage of the automatic decompression support, and then Mike shows an example of a Windows Phone and a Windows 8 version of an app that use the same portable class library containing HttpClient code for fetching images from Flickr.

If you want to take a deeper look at this demo and how it was built, take a look at this post on Mike Taulty's blog: Windows 8, Windows Phone 8: Building for Both.

IWP 61 | Building for Windows Phone and Windows 8 - The Basics

por Microsoft

One of the exciting elements of building for Windows Phone is that properly designed and architected Windows Phone apps are already on their way to being Windows Store apps. This week, Matt Hidinger joins us to talk about how we can leverage .NET technology to build apps for both platforms while sharing code.

In addition to his discussion here, you can also see Matt's Build 2013 talk in which he dives deeper into his Real World Stocks app. 

Build For Both: Windows and Windows Phone - Matt Hidinger

Real World Stocks source (Windows & Windows Phone)

One thing I've learned from talking about Build For Both is that you can never have enough samples or enough guidance. So in addition to Matt's code, Matthias Shapiro also has a "Build For Both" project build around the Philips Hue WiFi enabled lights that was also demoed at Build 2013. While the title of the talk is MVVM, the project features a complete solution for both Windows Phone and Windows. 

This App Is Brought to You by MVVM - Hulu Case Study - Matthias Shapiro and Zachary Pinter

Hue For Both - Windows and Windows Phone

Additionally, in the MVVM talk listed above Zachary Pinter from Hulu joined Matthias to talk about how Hulu created a "Build For Both" solution that shares code across projects. It is a fantastic demonstration of the power of good architecture to create apps that live on Windows and Windows Phone. As if that were not enough, Zachary also explains his techniques further in a post on the Hulu Tech Blog. 

Tips and Highlights From Developing Mobile Apps for Windows - Zachary Pinter

Finally, if you're more interested in reading that watching, check out the July 2013 issue of MSDN Magazine, which features an article from Joel Reyes on building apps for Windows 8 and Windows Phone 8. Joel's piece is one of the most complete discussions on the topic, covering details around UX strategies, application lifecycle, tiles, background tasks, you name it. 

Building Apps for Windows 8 and Windows Phone 8 - Joel Reyes

IWP60 | More on Imaging Scenario Resources for WP Developers

por Microsoft

We talked about imaging extensibility some more this week, specifically with regard to the samples we've provided for Windows Phone developers who want to add imaging scenarios to their apps.

Here are some details about the content we talked about, where to go to get more information and the specific examples we discussed:

Developer Documentation Resources on Camera/Imaging Scenarios

Great Sample Code on Camera/Imaging Scenarios (from the Windows Phone SDK Team)

Great applications that leverage Camera/Photos extensibility

Questions?

Tweet to @LarryALieberman or @matthiasshap

IWP 59 | Nokia Imaging SDK on Windows Phone

por Microsoft

Download the project seen in this video here.

Two weeks ago, Nokia announced their Lumia 1020, which, in addition to being a fantastic all-around device running the best mobile OS on the market today, has an astounding 41 megapixel camera sensor. In addition to this new device, Nokia also announced the public beta of the Nokia Imaging SDK.

The Nokia Imaging SDK is a really amazing library and almost instantly became one of my favorite packages for Windows Phone development. It works with any Windows Phone, not just the Nokia Lumia line. The SDK features 52 easy-to-use filters for mobile imaging and is able to apply them quickly and (my favorite part) with extremely low memory usage. Honestly, the word "filters" is a little deceptive because among these filters are filters to crop, rotate, combine multiple images and even add custom frames. With these options, the Nokia Imaging SDK is a full-featured imaging solution that is custom designed for the way Windows Phone development works.

The documentation around the SDK is excellent. Because Nokia took care to write libraries for specific chipsets, it is a good idea to carefully follow the instructions for adding the SDK to your project. Once the libraries are added and the project configured to work on both emulators and devices, you can jump into the Quick Start, which walks through capturing a new image and adding a filter to the image.

In addition to this simple tutorial, Nokia has also provided 3 great sample projects that feature the value of the SDK in a variety of contexts. Each of the demos is accompanied with an in depth discussion of how the demo works along with key code.

Filter Effects - Shows the power of combining filters by showing 4 filter combination pre-sets and allowing the user to manage the filter variables in real-time.

Filter Explorer - Pulls images from the user media library and applies random filters to them, arranging them in a tile schema. If you're looking for an easy example of all the available filters, this is the place to go.

Real-Time Filter Demo So... you're the difficult person who wants to apply filters in real-time in your app. There's a demo for that too! This demo shows off 6 of the filters in a real-time camera setting.

IWP 58 | Put the Standard Animations in your App

por Microsoft

One of the most beautiful design aspects of the Windows Phone OS is the use of motion design. Windows Phone is alive with motion, which acts as a huge differentiator in quality applications. Unfortunately, motion design can be very painstaking work and difficult to implement.

Fortunately the Windows Phone Toolkit has everything we need to implement powerful animations that bring your Windows Phone apps to life. In this video Shawn Oster walks us through the steps of adding the Windows Phone Toolkit and utilizing the transitions and tilt animations to make your app feel like a native part of the ecosystem.

To summarize our conversation, you can very easily add the basic page transition animation to your app in literally about 2 minutes.

Step 1: Install the Windows Phone Toolkit, or simple add the toolkit to your project using Nuget.

Note: If Nuget fails, check to see if an update is available from Tools > Extensions and Updates, under Updates > Visual Studio Gallery. You need Nuget >= version 2.1 to work with Windows Phone projects.

Step 2: (and we forgot to mention this in the video): In App.xaml.cs, locate:

RootFrame = new PhoneApplicationFrame;

and replace it with

RootFrame = new TransitionFrame();

Step 3: At the top of each page on which you want the transition to be used:

a. If the toolkit namespace is not defined, add it, (it will automatically be added if you have added any toolkit controls to the page previously):

xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;
     assembly=Microsoft.Phone.Controls.Toolkit"

Finally, add the following block fo XAML to each page, (above the LayoutRoot),

     <toolkit:TransitionService.NavigationInTransition>
        <toolkit:NavigationInTransition>
            <toolkit:NavigationInTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardIn"/>
            </toolkit:NavigationInTransition.Backward>
            <toolkit:NavigationInTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardIn"/>
            </toolkit:NavigationInTransition.Forward>
        </toolkit:NavigationInTransition>
    </toolkit:TransitionService.NavigationInTransition>
    <toolkit:TransitionService.NavigationOutTransition>
        <toolkit:NavigationOutTransition>
            <toolkit:NavigationOutTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardOut"/>
            </toolkit:NavigationOutTransition.Backward>
            <toolkit:NavigationOutTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardOut"/>
            </toolkit:NavigationOutTransition.Forward>
        </toolkit:NavigationOutTransition>
    </toolkit:TransitionService.NavigationOutTransition>

IWP 57 | Location and Mapping for Windows Phone 8

por Microsoft

In this week's Inside Windows Phone we talk about Location and Mapping in Windows Phone 8.

In this video we cover

  1. The basics of location and mapping
  2. The power of Windows Phone location and mapping APIs including simple ways to do distance calculations, reverse geocoding (get an address from a latitude/longitude), mapping routes (both walking and driving) and how to point users to download offline maps to drive a powerful mapping experience available worldwide even in the absence of network connectivity.

All code from this video is available here.

Getting started with location in Windows Phone takes about 5 minutes.

Windows Phone Location and Mapping in 5 Minutes

Minute 1: Enable your app for mapping and location tracking.

Open up a new Windows Phone 8 project. Double-click on the WMAppManifest.xml file

 Generic Episode Image

Go to the Capabilities tab and check the ID_CAP_LOCATION and ID_CAP_MAP capabilities.

 Generic Episode Image

This gives you application permission to use the location APIs and the Map control.

Minute 2:  Add a map control.

Open up your MainPage.xaml in either Visual Studio or Blend. Go to the Toolbox in Visual Studio or the Assets pane in Blend and type "Map" in the search box. Double click or click-and-drag to add it to your XAML control.

In Visual Studio 2012:

Generic Episode Image

In Blend for VS 2012

Generic Episode Image

Minute 3: Get your location

Open up MainPage.xaml.cs (also known as your code-behind). Add a Geolocator variable and initialize it in your constructor. You will need to add Windows.Devices.Geolocation as a reference.

Geolocator locator;  

public MainPage()
{
    InitializeComponent();
    locator = new Geolocator();
    this.Loaded += MainPage_Loaded;
}

Change your MainPage_Loaded to enable await operations by adding "async" before "void" and add the following code:

async void MainPage_Loaded(object sender, RoutedEventArgs e)
{
    try
    {
        Geoposition myLocation = await locator.GetGeopositionAsync();
        GeoCoordinate geoCord = new GeoCoordinate(myLocation.Coordinate.Latitude, myLocation.Coordinate.Longitude);
    }
    catch (Exception exception)
    {
    }            
}

We want to wrap our attempt to get the Geoposition in a try-catch so that if it fails we don't crash our app. This could fail if the user turns off the ability of the app to get a location or if no location is available due to lack of connectivity and GPS access.

Minute 4: Update the map to your location

Give your map control a name so that we can reference it in our code-behind

<maps:Map x:Name="MyFirstMap" Grid.Row="1"/>

And set the GeoCoordinate that we created in minute 3 to the Map.Center property. To help us orient a little better, let's also set the zoom level to 14.

async void MainPage_Loaded(object sender, RoutedEventArgs e)
{
    try
    {
        Geoposition myLocation = await locator.GetGeopositionAsync();
        GeoCoordinate geoCord = new GeoCoordinate(myLocation.Coordinate.Latitude, myLocation.Coordinate.Longitude);
        MyFirstMap.Center = geoCord;
        MyFirstMap.ZoomLevel = 16;

    }
// And so on...

Minute 5: Update your location as it changes

Finally, let's set the movement threshold on our Geolocator to 50 meters (the locator object will only raise a position changed event when the device moves more than 50 meters from the last location) and start listening for when the position changes.

locator.DesiredAccuracy = PositionAccuracy.High;
locator.MovementThreshold = 50;
locator.PositionChanged += locator_PositionChanged;
Geoposition myLocation = await locator.GetGeopositionAsync();
// etc...

In the event handler, we'll look at our new position and re-center our map accordingly. One thing we need to remember is that, for performance reasons, this event handler reports on a background thread. In order to update our Map control UI, we need to move to the UI thread using Dispatcher.BeginInvoke.

void locator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
{
    Dispatcher.BeginInvoke(() =>
    {
        GeoCoordinate newGeoCoord = new GeoCoordinate(
            args.Position.Coordinate.Latitude, 
            args.Position.Coordinate.Longitude);
        MyFirstMap.Center = newGeoCoord;
    });
}

Bonus Minute: Emulate location updates

And now we have an app that tracks our location and displays it on a map. To update the location and watch those updates track in your app, open the additional tools using the button indicated below.

Generic Episode Image

Under the location tab, just click or tap on the map and the updated location will be indicated in your app. You can even load up a file of pre-defined GeoCoordinates (up to 99) and play them in the emulator so you can test constantly changing coordinates in your app. The file we used is a set of coordinates emulating a jog around the Microsoft campus.

You can download that file here.  Load the file by clicking on the Load button under "Recorded Data" in the Location emulator tab. For the best fake running experience have the emulator fire a new point every 5 seconds and hit the play button. For easy access, place the file in the "...My Documents/WindowsPhoneEmulator/Location" folder.

Generic Episode Image

Other Things That Are Easy

The second demonstration app we showed the following features from the Windows Phone API. We don't want to overload this post with too much, so these are available as individual posts.

Calculating Distance Between 2 GeoCoordinates

Reverse Geocoding

Mapping Walking and Driving Routes

Offline Mapping

Practical MVVM For Windows Phone

por Microsoft

In the world of Windows Phone development, the cornerstone app architecture is called MVVM (Model-View-ViewModel). In this video, I talk through some of the structure of an MVVM application to talk about how we build MVVM apps for the phone to take advantage of benefits like data binding, commanding and ViewModel portability.

MVVM is an enormous topic. In addition to this video, you should take a look at the following articles, videos and blog posts to learn more about the why and the how of MVVM.

These two posts are targeted at Windows Phone Mango (7.5) but all the code carries across to Windows Phone 8 as well.

Getting Started with MVVM in 10 minutes

Building a Reusable ICommand implementation for Windows Phone MVVM apps

 

Laurent Bugnion, who leads the fantastic MVVM Light Toolkit project, has a 4-article MSDN series on MVVM

IOC Containers and MVVM

Messenger and View Services in MVVM

Maximizing the Visual Designer's Usage with Design-Time Data

Commands, RelayCommands and EventToCommand

 

And finally, more videos:

Designing Awesome XAML apps for Windows 8 and Windows Phone 8 (Build 2012)

Create Cross-Platform Apps using Portable Class Libraries (Build 2012)

Understanding the Model-View-ViewModel pattern (MIX10)

Deep Dive MVVM (MIX 11)

 

Developing in HTML5 and Javascript for Windows Phone

por Microsoft

 One of the really exciting things about Windows Phone development is how enormously flexible it is. With Windows Phone 8, in addition to supporting native (C++) and managed (C#) development, the platform is the perfect place to develop apps using HTML5.

Jeff Burtoft,  an HTML5 technical evangelist with Microsoft, joins us this week to talk about the flexibility and cross-platform power of HTML5 in the context of Windows Phone. The in-depth example that we cover in the video is a project called YetiBowl, and standards compliant HTML5 game that runs flawlessly on the web, as a Windows 8 app and as a Windows Phone 8 app.

Make sure you check out Jeff's 4 part series on creating the HTML5 Yeti game you see in this episode.

Yeti Bowl Part 1, Part 2, Part 3, Part 4

What makes all this possible is Internet Explorer 10 on Windows Phone 8. IE10 for the phone and the PC are built on the same engine and use the same renderer which means that what you see on your desktop (or tablet) is what you'll see on your phone. Additionally, the web browser control in Windows Phone apps is a full instance of IE10, with the same speed and power as the native phone browser.

There are lots of great libraries and products that make developing for Windows Phone 8 in HTML5 a blast.

  • PhoneGap - PhoneGap is for building cross-platform apps using HTML5. They support Windows Phone 8 with a great Visual Studio template to get started in no time. And don't miss our PhoneGap porting challenge with great opportunities prizes available for PhoneGap developers.  
  • Atari Arcade - Great HTML5 games that re-imagine the some of the classic Atari games. Get the source code and get coding!
  • Internet Explorer Test Drive - great examples of what is possible using IE 10.
  • CreateJS - A great library for building rich experiences in HTML5 that work beautifully on Windows Phone.
  • ProcessingJS for Windows and Windows Phone - The ProcessingJS library uses HTML5 canvas to create digital art, simple games and visualizations. We have a full curriculum on creative coding including sample projects and full-featured apps.
  • Construct 2 - HTML5 based game creator focused on building beautiful 2D HTML5 games. Support for both Windows Phone 8 and Windows Store apps.
  • YoYo GameMaker - Cross-platform HTML5 game development with support for Windows Phone 8 and Windows 8.

 

 

 

IWP54 | Windows Phone Data Binding and the Magic of XAML

por Microsoft

Download the sample project seen in this video.

Data binding is one of the fundamental concepts for good Windows Phone application design but can be difficult to grasp for newcomers. The core concept is this: No one wants to manually update the user interface elements. I want my UI to automatically reflect the state of my application and data binding helps us do this. We can work exclusively on our Windows Phone UI, bind the values in the UI and then work on the inner logic of the application knowing that all the updates are being reflected to the user. Because of the power in the model you see in this video and post, there are some really great "fringe" benefits in terms of interaction and design that we get along with the core benefits.

So let's build our first data binding. By a happy coincidence, this can also be our first ViewModel from scratch.

I use Visual Studio snippets in the video and in "real life" because it's substantially faster and I have a very poor memory. You can download the notify property snippets I used here. Just extract them into your "Documents\Visual Studio 2012\Code Snippets\Visual C#\My Code Snippets" folder and you should be ready to go.

As a "first steps" post, we're going to go through how to build a data binding step by step. To see this model in action, just open up a new

My First Data Binding

In our app, lets create a new ViewModel. I right-clicked in the ViewModel folder and went to "App -> Class..." and created just an empty Class file named "SampleViewModel.cs". This class now looks like this:

class SampleViewModel
{
}

We update it to implement the INotifyPropertyChanged event by declaring that interface and using the "notifyInterface" snippet. Hit Alt-Shift-F10 to resolve any refrerences (specifically the System.ComponentModel) and our code should now look like this:

public class SampleViewModel : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;

    protected void NotifyPropertyChanged(string propertyName)
    {
        PropertyChangedEventHandler handler = PropertyChanged;
        if (handler != null)
        {
            handler(this, new PropertyChangedEventArgs(propertyName));
        }
    }     
}

Now we can just start creating properties we want to see reflected in our UI. Using our "notifyProp" snippet, we can quickly create a property like the string SampleUserName.

private string _sampleUserName = "";
public string SampleUserName
{
    get { return _sampleUserName; }
    set
    {
        _sampleUserName = value;
        NotifyPropertyChanged("SampleUserName");
    }
}

Now our property is ready to be bound to our XAML.

Define Your Data Context

This part can be skipped for brevity, but I wanted to add it to make sure that there is a complete and comprehensive solution here.

Before our XAML can bind to this property, we need to make the ViewModel visible to our XAML. So we will declare our ViewModel as a static object in our App.xaml.cs

private static SampleViewModel _sampleVM { get; set; }
public static SampleViewModel SampleVM
{
    get{
        if (_sampleVM == null)
            _sampleVM = new SampleViewModel();
        return _sampleVM;
    }
}

Then we can set the data context when our XAML view initializes. In the MyView.xaml.cs (also called the "code behind), we can add to the constructor:

public MyView()
{
    InitializeComponent();
    this.DataContext = App.SampleVM;
}

This way we could have the same ViewModel driving multiple Views. This is particularly valuable for a Master-Detail scenario in which we have one View dedicated to showing a list of items and another View for editing or looking at an item detail. With this method, we can maintain a single ViewModel and simply update which item has been selected.

XAML Binding

With our viewmodel defined and our notify properties set up, all we need to do is bind to our XAML UI control. Then any updates we make to our property back in the ViewModel will automatically update in the XAML UI.

<TextBox Text="{Binding SampleUserName}" />

And if we wanted changes to the UI to be updated back in our ViewModel, we just set our binding to "TwoWay"

<TextBox Text="{Binding SampleUserName, Mode=TwoWay}" />

Binding, Sample Data, and Design

In addition to helping us build manageable code with a simple model for XAML UI updates, binding allows us to build our app interfaces in a way that is fast and powerful. Instead of run-view-tweak, run-view-tweak, we can explore design options and do most of our design right inside our tooling without running the application. In fact, if you follow the steps here, you can actually build much of the interaction and XAML of an application up before you start building the logic. The result is the opportunity for a workflow that supports design-driven user-focused application creation.

For this, we're going to move away from our SimpleViewModel with its single property and into a real-world example that
focuses on binding with real-world data.
To follow along in this example, download this slightly modified version of the LongListSelector Infinite Scroll example for Windows Phone.

Because we're working with sample data, we want to open the project in Blend.

  1. Open up the MainPage.xaml file and go to the Data tab at the top right corner.
  2. Select the project data store and click on the "Create sample data -> Create Sample Data From Class" button.

Generic Episode Image

 You'll get a dialog box that allows you to name your data source and select a class from which Blend will generate the data.

Generic Episode Image

Blend will do a "best guess" on what data is in there based on the data types. String will default to lorem ipsum sample text, and int will generate a number, an ObservableCollection will result in a generated list of sample objects. All this data will be saved as a XAML resource file in the SampleData folder. To create bindings for these objects, all we would have to do is drag the object from our Data tab to an control in our "Objects and Timeline" tab.

We could go into this file and edit the data to be something that is a little more realistic for our application. In fact, this is exactly what I've done. For this Twitter app, I added some actual tweets from my timeline as sample data. To see this click on the eye icon next to the "resultListBox".

 Generic Episode Image

And now we can see the sample data and how it will look in the application.

Generic Episode Image

Here is where it gets really fun: Right-click on the resultListBox and select "Edit Additional Templates -> Edit ItemTemplate -> Edit Current".

Generic Episode Image

This will take you to a XAML DataTemplate where we can define, in real time and against real data, how we want our items to be displayed. We could give our tweet text a height limit and tell it to use ellipses and see that reflected instantly in our design.

<TextBlock Text="{Binding Tweet}" 
   MaxHeight="40"
   TextTrimming="WordEllipsis" />

Generic Episode Image

As you can see, this is an incredibly powerful way to design and build applications for Windows Phone and it is all made possible by DataBinding.