DCSIMG
Alex Golesh's Blog About Silverlight Development

Utility: Extmap Maker v1.1

Quite some time ago, I wrote small utility which helped to create external map manifest file for Silverlight assemblies. This manifest is needed to enable XAP reduction feature (you can read more about it here).

I have been told, that the utility is not working with assemblies compiled with Silverlight 5, so I decided to update it. The new version compatible with Silverlight 3, 4 & 5 assemblies.

Please note, that new version requires .NET 4.0 Client profile in order to work.

Updated version can be downloaded from here.

 

Stay tuned,

Alex

Sela Developer Practice–December 2011

Announcing – Sela Developer Practice conference (third time) will take time at Crown Plaza hotel (Tel Aviv, Israel) and the SELA headquarters (Bnei-Brak, Israel) on December 4-8, 2011.

image

This year the conference will focus mostly on Windows 8 and other hot announcements made during //BUILD conference earlier this year at Anaheim, CA.

During Sela Developer Practice (SDP) this year, Sela experts and special guests from Microsoft Israel (Guy Burstein and Maor David-Pur) will talk about new features in Windows 8, Visual Studio 2011, .NET Framework v4.5 and other hot technology topics. First conference day will be a day full of keynote sessions and next 4 days will be hosted as 22 full-day tutorials on a wide variety of topics.

During first day I will present a session about Live Tile and Notifications on Windows 8 (look for “Engaging Users with Live Tiles and Notifications” session at agenda) and then will full-day tutorial about Windows Phone v7.5 “Mango” (look for “Windows Phone Mango” tutorial day at agenda).

The registration is open! If you’re considering attending, act fast – last time most of tutorial days sell out a few weeks before the conference.

 

See you @SDP11

Alex

My Session at UNETAPlus

image

Few hours ago I delivered a session about creating Silverlight/XNA hybrid applications for Windows Phone Mango. I like to thank all the participants – you were great and I had a great pleasure to present for such quality audience. I loved the questions and the conversation after the session.

The slides deck I used for presentation can be download from the here.

 

As promised, the demo applications also published and can be downloaded from the following locations:

  • Demo #1 is here.
  • Demo #2 is here.
    • This application is also published on Windows Phone Marketplace and if you are happy owner of Windows Phone Mango phone it could be found and downloaded from here.

 

Thanks and stay tuned for more updates,

Alex

Windows 8 To Go

Today was most interesting day so far at //BUILD Windows conference. I’ve attended few interesting sessions, but one of them was absolutely amazing. The session focused on Windows 8 To Go – a way create fully working bootable copy of Windows 8 which can be used to boot any PC (and not only PC – I’ve tried it on my brand new Windows 8 Tablet) and have fully working environment. This opens new horizons to companies, independent software developers, consultants and instructors (like myself) to have fully configured and working environment in pocket always ready to go. This option also leaves the physical machine running Windows 8 To Go absolutely intact. The session had a cool demos of almost-instant boot from USB 3.0 bootable USB-stick, but coolest one was suspending and resuming Windows 8 To Go controlled machine while USB-stick is pulled from the PC – the demo was to present video and pull the stick during the video. Then the machine stopped and when the USB-stick were inserted back it resumed from the same place.

After the session all the attendees got the personal Windows 8 To Go USB-stick – Kingston 32Gb USB 3.0.

We (me and Sasha Goldshtein) decided to check how it works on devices and booted my Windows 8 tablet.

It worked, but it was kinda expected. Then we tried to boot Sasha’s MacBook Air from the USB stick.

First setup took some time but finally it worked:

Subsequent boots were very fast and PC worked very zippy. The boot video:

After short boot-up Windows 8 start screen appeared:

We tried to start Visual Studio 2011 Express Edition and it loaded super-fast:

Finally we trued the same experiment with pulling out the USB stick from working machine and it worked:

Very very impressive!

 

I’m learning the new stuff and very soon will post cool articles about Windows 8 development.

Stay tuned for more updates,

Alex

Vote for my sessions at TechDays Canada 2011

My sessions made into short voting list to TechDays Canaga 2011. My sessions are:

  • WIN314 - Mango: Silverlight and XNA – Better together!
  • WIN319 - Mango: Search Integration
  • WIN320 - Mango: Background Agents at Work

Vote for my sessions at:

http://bit.ly/tdcan2011vote

 

Thanks,

Alex

Meet me at BUILD

BUILD/Windows approaching fast. As previous years with PDC, also this time SELA sends around 20 top experts to BUILD. I will be there also Smile

If you want to meet me or someone of other SELA experts to discuss some exciting news I’m sure we are going to get at BUILD (or just say “Hi”) feel free to send me a tweet @DevCorner.

 

See you at BUILD,

Alex

vNext

Something BIG is happening those days...

Come and join new development community at vNext.org for exciting technology content!

Many unique content, latest tech news and other hot development topics soon to be revealed.

 

Stay tuned,

Alex

Silverlight 5 goes RC!

Silverlight 5 RC just released! This release includes some changes from Beta release – make sure you are reading the documentation and change your applications accordingly. Also, it includes some features announced before, but unavailable in Beta version.

To install you must run Visual Studio 2010 SP1 – if you still not updated your environment download it form here.

Download Silverlight 5 RC Developer runtime for 32-bit Windows here and for 64-bit Windows here. Mac downloads links: 32-bits and 64-bits.

Download location of Silverlight 5 RC SDK is here.

Silverlight 5 RC tools for Visual Studio 2010 SP1 are here.

Finally, WCF RIA Services for Silverlight 5 RC located here.

 

Download and try the new version today!

 

Stay tuned for more news to come,

Alex

Posted by Alex Golesh | with no comments

Windows Phone 7.1 (Mango) Developer Tools–RC Release!

Microsoft just released a new refresh of Windows Phone Mango developer tools (WPDT) – the RC. This release includes “Go Live” license that permits registered developers to publish Mango applications to the Marketplace!

What changed/added:

  • The profiler has been improved, and now provide memory profiling as well
  • The emulator has a couple improvements to make development and testing better:
    • The RTM build (build 7720) is used by the emulator, providing you with confidence that the code you write will work on Windows Phone 7.5 retail devices
    • A screenshot capability is now also built-in, allowing you to quickly capture images of your app in action
      image
  • NuGet is now supported in the free Visual Studio 2010 Express for Windows Phone SKU, allowing you to easily keep your add-ons up to date
  • The completed Marketplace Test Kit enables you to test your app for certification on your machine, running the same technical certification tests that the Marketplace team runs, which should dramatically improve your chances of passing the first time
    image

The links:

WPDT SDK v7.1 download here.

WPDT SDK v7.1 full ISO image direct download link.

New code samples here

What’s new article here

 

Stay tuned,

Alex

“Off topic” - Google: You liked hamburger? We know where you want to shop for outdoor activities gear!

Today I was pretty amazed and decided to share my experience! Here it goes…

I am at business trip in Redmond, WA. Yesterday I had a launch at one of Red Robin's restaurants near my hotel at Overlake shopping center. I found the place using Latitude application on my Android phone and since the burger was very good, decided to “check-in” into the place and even had a small positive review:

imageimage

Today I decided to go shopping for some “outdoor activities” gear and searched for REI store. For my complete surprise search engine suggested me some specific store based on my previous activities online:

image

I was simply amazed! This is definitely “intelligent” way to improve search results Smile

Keep it up, Google!

 

Alex

Posted by Alex Golesh | with no comments
תגים:,

I’m Microsoft MVP for Third Time!

About 15 minutes ago, I received an email presenting me with the Microsoft MVP Award in Silverlight!

image

I am very honored to receive an MVP Award for third time in row and I will continue contributing to the online and offline developer community in Israel and abroad.

This is a great opportunity and place to thank quite a few people who helped me to win this Award for third time:

  • My wife and daughter for having so much patience and providing the best support I could only dream about!
  • My current and past managers (David, Ishai, Caro) and coworkers at Sela Group, which is easily the best software company to work for that I could think of;
  • All other peoples who helped me get this MVP award;

Stay tuned for posts on Silverlight and Windows Phone 7!

Alex

Windows Phone Mango – New Tasks (Beta & Beta2)

Windows Phone Mango adds few more task over initial Windows Phone (RTM) release. This post will cover new task (launchers and choosers) added to Windows Phone Mango Beta and Beta 2.

To introduce those features I’ve created sample application which looks very simple, yet have all those new tasks:

image

Before we are starting, one very important note about tasks in general. Some of them works on emulator as on real device (Bing maps, Bing directions, etc.), some of them works but doesn’t produce any “visible” output and cannot been verified (Save Ringtone) and some of them are not working at all. In order to take full advantage of task please consider using windows phone mango developer enabled device.

Let’s see the new tasks one by one. GameInviteTask used to display game invite screen to invite users into a multiplayer game session. This task works also for non-game scenarios, and in this case serves as application promotion:

private void btnGameInvite_Click(object sender, RoutedEventArgs e)

{

    GameInviteTask gameInviteTask = new GameInviteTask();

    gameInviteTask.SessionId = "SomeSessionID";

    gameInviteTask.Completed += new EventHandler<TaskEventArgs>(gameInviteTask_Completed);

    gameInviteTask.Show();

}

 

void gameInviteTask_Completed(object sender, TaskEventArgs e)

{

    if (null == e.Error)

    {

        MessageBox.Show(string.Format("Invite {0}sent!", (e.TaskResult == TaskResult.Cancel ? "not " : "")));

    }

    else

        MessageBox.Show("Error sending invite!");

}

This code snippet presents the following UI:

image

Next the Bing-related tasks. Many time you application want to present some geographic location without including Bing maps control into the application. In such case in Mango we can leverage BingMapsTask. This task uses search term to locate the point of interest and optionally zoom level and geographical position for centering the map and shows it on separate screen:

private void btnBingMaps_Click(object sender, RoutedEventArgs e)
{
    BingMapsTask bingMapsTask = new BingMapsTask();
            
    bingMapsTask.SearchTerm = "Eiffel Tower, Paris, France";
    bingMapsTask.ZoomLevel = 21;
    bingMapsTask.Show();
}

Executing the task leads to the following result:

image

If you application needs to provide driving/walking directions it can be achieved using BingMapsDirectionsTask:

private void btnBingDirections_Click(object sender, RoutedEventArgs e)
{
    BingMapsDirectionsTask bingMapsDirectionsTask = new BingMapsDirectionsTask();
    LabeledMapLocation start = new LabeledMapLocation();
    GeoCoordinate startLocation = new GeoCoordinate(48.51489, 2.1767119);
    start.Label = "Eiffel Tower, Paris, France";
    start.Location = startLocation;
 
    LabeledMapLocation end = new LabeledMapLocation("Louvre, Paris, France",
        new GeoCoordinate(48.516396, 2.2026199));
 
    bingMapsDirectionsTask.Start = start;
    bingMapsDirectionsTask.End = end;
    bingMapsDirectionsTask.Show();
}

Note: Your application can use GeoCoordinateWatcher class to resolve current device position and set it as start location for directions task.

The result presented as navigation sequence supported by voice directions:

image

Last Beta task is SaveRingtoneTask. This task enables your application to add custom ringtones to your device. The sound files should be placed in application data or isolated storage. In this sample I’ve added sample MP3 file as a content resource to my application and copy it into my application IsolatedStorage before executing the task:

private void btnSaveRingtone_Click(object sender, RoutedEventArgs e)
{
    using (IsolatedStorageFile iso = IsolatedStorageFile.GetUserStoreForApplication())
    {
        Stream str = Application.GetResourceStream(new Uri("Sound/Sound.mp3", UriKind.Relative)).Stream;
 
        IsolatedStorageFileStream outFile = iso.CreateFile("Ring.mp3");
 
        outFile.Write(ReadToEnd(str), 0, (int)str.Length);
        str.Close();
        outFile.Close();
    }
 
    SaveRingtoneTask ringtoneTask = new SaveRingtoneTask();
 
    ringtoneTask.Source = new Uri("isostore:/Ring.mp3", UriKind.Absolute);
 
    ringtoneTask.Show();
}
 
private static byte[] ReadToEnd(System.IO.Stream stream)
{
    long originalPosition = stream.Position;
    stream.Position = 0;
    try
    {
        byte[] readBuffer = new byte[4096];
        int totalBytesRead = 0;
        int bytesRead;
 
        while ((bytesRead = stream.Read(readBuffer, totalBytesRead, readBuffer.Length - totalBytesRead)) > 0)
        {
            totalBytesRead += bytesRead;
            if (totalBytesRead == readBuffer.Length)
            {
                int nextByte = stream.ReadByte();
                if (nextByte != -1)
                {
                    byte[] temp = new byte[readBuffer.Length * 2];
                    Buffer.BlockCopy(readBuffer, 0, temp, 0, readBuffer.Length);
                    Buffer.SetByte(temp, totalBytesRead, (byte)nextByte);
                    readBuffer = temp; totalBytesRead++;
                }
            }
        }
 
        byte[] buffer = readBuffer;
 
        if (readBuffer.Length != totalBytesRead)
        {
            buffer = new byte[totalBytesRead];
            Buffer.BlockCopy(readBuffer, 0, buffer, 0, totalBytesRead);
        }
 
        return buffer;
 
    }
    finally
    {
        stream.Position = originalPosition;
    }
}

image

Note: this is one of those tasks, which actually works on emulator, but cannot be verified – the emulator simply have no interface to check the ringtones.

Now let’s see Beta 2 additions. In Beta 1 we got an ability to search for contacts (I’ve blogged about it here). Now we can populate a new contact data and enable user simply saving it:

private void btnSaveContact_Click(object sender, RoutedEventArgs e)
{
    SaveContactTask saveContactTask = new SaveContactTask();
    saveContactTask.Company = "Sela Group";
    saveContactTask.FirstName = "Alex";
    saveContactTask.LastName = "Golesh";
    saveContactTask.JobTitle = "Senior Consultant, Mobile Division Manager";
    saveContactTask.WorkEmail = "alexg@sela.co.il";
    saveContactTask.Website = "http://blogs.microsoft.co.il/blogs/alex_golesh/";
    saveContactTask.Nickname = "@DevCorner";
    saveContactTask.Completed += new EventHandler<SaveContactResult>(saveContactTask_Completed);
    saveContactTask.Show();
}
 
void saveContactTask_Completed(object sender, SaveContactResult e)
{
    if (null == e.Error)
    {
        MessageBox.Show(string.Format("Contact {0}saved!", (e.TaskResult == TaskResult.Cancel ? "not " : "")));
    }
    else
        MessageBox.Show("Error saving contact!");
}

User presented with the following UI which enables him to change any suggested values and save the contact:

imageimage

Last two are about social features. They enabling to share user status and link (on Windows Live, Facebook, etc. for example):

private void btnShareStatus_Click(object sender, RoutedEventArgs e)
{
    ShareStatusTask shareStatusTask = new ShareStatusTask();
    shareStatusTask.Status = "My phone just turn fruit!";
    shareStatusTask.Show();
}

 

private void btnShareLink_Click(object sender, RoutedEventArgs e)
{
    ShareLinkTask shareLinkTask = new ShareLinkTask();
    shareLinkTask.Message = "Visit my blog for new Windows Phone ‘Mango’ content!";
    shareLinkTask.Title = "My Blog";
    shareLinkTask.LinkUri = new Uri("http://blogs.microsoft.co.il/blogs/alex_golesh/", UriKind.Absolute);
    shareLinkTask.Show();
}

ShareStatusTask enables to change current status line and ShareLinkTask enables sharing some link along with title and description:

image

Note: those two launchers doesn’t works on the emulator – they are not producing any changes since there is no way to connect the emulator to the Live/Facebook accounts. You will need real Mango device connected to Facebook in order to check it.

 

Sources for this sample hosted here.

 

Stay tuned for more to come.

Alex

Windows Pone Mango–Developer Tools Beta 2 released!

Microsoft just released Beta 2 refresh of Windows Phone Mango developer tools!

The refresh further improves the tools, resolves bugs from previous release and adds some new features.

Most important – registered Windows Phone developers with retail device will get access to Mango updates via invites to Microsoft Connect site which will give them access to Mango for their retail devices!

Also, the release brings some breaking changes which we as developers need to be aware of. Here are the list of some breaking changes:

Change Improvement Resolution
Image decoding moved to the background thread Enables more responsive UI If background loading of an image is not suitable, change the CreateOptions of the image from BackgroundCreation to DelayCreation in either the XAML or the code-behind.
Asynchronous web client request that was generated on a background thread returns to the background thread pool. Enables complete background processing of downloads and leads to more responsive UI In code that relies on the response returning on the UI thread, marshal the response using Dispatcher.BeginInvoke
The OnCancel override method was removed from the ScheduledTaskAgent class   Remove this method from your application code
The MotionReading property types have changed This change eliminates the dependency between MotionReading, AccelerometerReading, and GyroscopeReading Code that uses the MotionReading class must change to use the new types and name
The Background Transfer Service folder in isolated storage was renamed This change groups all services that access files in the isolated storage under “Shared” Change all references from DownloadLocation, UploadLocation, and the source URI of the BackgroundTransferRequest constructor to point to “Shared\Transfers” instead of “Transfers”.
Tile data in isolated storage must use the folder Shared\ShellContent This change groups all services that access files in the isolated storage under “Shared”

Change all references from BackBackgroundImage and BackgroundImage to point to Shared\ShellContent. For example:   
BackgroundImage  image = new Uri("isostore:/Shared/ShellContent/TileBackground.jpg", UriKind.Absolute)

The ShellTileEnumerator class was removed The standard IEnumerable<T> interface is all that is needed when using the ShellTile.ActiveTiles Enumerate ActiveTiles by using the recommended IEnumerable patterns such as for-each
Background agents are not launched in the debugger by using the Add and Find methods The new LaunchForTest method makes it easier to debug background agents Use the LaunchForTest() method to debug background agents. For example:
PeriodicTask periodicTask = new PeriodicTask("TheWorker");
periodicTask.Description = "The worker task";
periodicTask.ExpirationTime = DateTime.Now.AddDays(1);
 
ScheduledActionService.Add(periodicTask);
 
if (System.Diagnostics.Debugger.IsAttached)     
ScheduledActionService.LaunchForTest("TheWorker", TimeSpan.FromSeconds(10));
Hardware camera button events removed from PhotoCamera class New CameraButtons static class enables same creating shared event handlers for hardware button events functionality Application code which uses PhotoCamera’s “OnButtonHalfPress”, “OnButtonFullPress”, and “OnButtonRelease” should use corresponding new events from CameraButtons’ “ShutterKeyHalfPressed”, “ShutterKeyPressed” and “ShutterKeyReleased”. For example:

//Event is fired when the button is half pressed
CameraButtons.ShutterKeyHalfPressed += camera_ButtonHalfPress;

//Event is fired when the button is fully pressed
CameraButtons.ShutterKeyPressed += camera_ButtonFullPress;

In addition, the Beta 2 adds some new launchers and choosers which will be covered in additional post.

Download Windows Phone Developer Tools Beta 2 here.

Stay tuned to more to come!

Alex

Windows Phone Mango–What’s New? (“Profiler” - Part 9 of 8)

This post is a “missing part” of series about new features in Windows Phone Mango Smile

New and very important feature of Windows Phone “Mango” Developer Tools is the profiler. The profiler enables the developers of Silverlight applications (currently only Silverlight scenarios are supported) to sense important heartbeats of the application and collect information about application behavior at runtime.

To measure the performance or the application, navigate to Debug menu option and select Start Windows Phone Performance Analysis:

clip_image001

Visual Studio provides the developer with configuration setting screen which enables him to define some profiling settings, like drawing details, depth of stack frames in each collection, data collection frequency and others:

clip_image002

Finally, when “Launch Application” button pressed, the application starts on selected target (Emulator or Device) and developer should execute the regular application flow (actions). Visual Studio collects the data in the background:

clip_image003

Profiling stopped by clicking “Stop Profiling” button; the application terminates and Visual Studio transfers the measured data into the developers’ PC for analyzing and graphical representation:

clip_image004

Once the data is ready it is presented to developer along with some warnings and recommendations based on application behavior:

clip_image006

Based on selection, and in addition to those warnings, the developer presented with detailed graphs of Draw Frame Rate, CPU and memory usage, running storyboard, images load and garbage collects. In addition, the lower part enables the developer to browse through various presentations of sampled data:

clip_image007

For example check which Visual elements were presented in each single frame and which visual types builds those elements:

clip_image008

hhich active storyboards running at specified period of time:

clip_image010

how log takes to render the application’s Visual Tree:

clip_image012

and many others.

Stay tuned for more posts to come.

Alex

Windows Phone Mango–What’s New? (“Push Notifications & Tiles” - Part 8 of 8)

Mango introduces some changes in Push Notifications mechanism which enables the developers to create more attractive scenarios.

First feature I’ll show in this post is a secondary tiles for application. Before Mango, every application could have only one pinned tile on the main screen which could be updated using Push Notification mechanism (I blogged about it quite some time ago here and here).

Mango release enables to have additional tiles which can be pinned and removed from application code! How about having something like this:

imageimage

All the tiles (beside IE9) on main screen are related to sample I’m going to show here… And they are flipping randomly! Clicking on the tile will take us directly to the person’s mood page:

image

The UI of the app will be very simple – only a bunch of checkboxes to create/remove secondary tiles:

image

Checking the checkbox will add corresponding secondary tile to the main screen; unchecking the checkbox will remove it.

Let’s see how to achieve it. First, my application uses PushNotification channel created (or found) when application loaded:

//Check push channel status and subscribe to the events
pushChannel = HttpNotificationChannel.Find("MoodPushChannel");
if (null == pushChannel)
{
    pushChannel = new HttpNotificationChannel("MoodPushChannel");

    SubscribeToChannelEvents();

    pushChannel.Open();

    pushChannel.BindToShellTile();
}
else
{
    SubscribeToChannelEvents();

    uri = pushChannel.ChannelUri;

    if (!pushChannel.IsShellToastBound)
        pushChannel.BindToShellToast();

    // Uri for diagnostic -- to use from server side
    if (null != uri)
        Debug.WriteLine(uri.ToString());
    else
        Debug.WriteLine("PushChannel.ChannelUri is null");
}

In my sample I’ll use the debug output to pickup the channel URI and use it for sending notifications from cloud-based website:

image

In case of this simple application I don’t really need RAW Notifications and TOAST notifications, so I’ll subscribing only for ChannelUriUpdates and ErrorOccured events:

private void SubscribeToChannelEvents()
{
    pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
    pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);
}

void PushChannel_ChannelUriUpdated(object sender, NotificationChannelUriEventArgs e)
{
    uri = e.ChannelUri;

    if (!pushChannel.IsShellToastBound)
        pushChannel.BindToShellToast();

    Dispatcher.BeginInvoke(() =>
    {
        Debug.WriteLine(uri.ToString());
    });
}

void PushChannel_ErrorOccurred(object sender, NotificationChannelErrorEventArgs e)
{
    Dispatcher.BeginInvoke(() =>
        MessageBox.Show(String.Format("A push notification {0} error occurred.  {1} ({2}) {3}",
            e.ErrorType, e.Message, e.ErrorCode, e.ErrorAdditionalData)));
}

Now let’s see how to create a secondary tile (one of checkbox’s event handlers function):

private void chkAlex_CheckedUnchecked(object sender, RoutedEventArgs e)
{
    if (!StillInitializing)
    {
        if (chkAlex.IsChecked.Value)
        {
            StandardTileData initialData = CreateTile("Alex");
            ShellTile.Create(new Uri("/MoodInfo.xaml?Name=Alex", UriKind.Relative), initialData);

        }
        else
        {
            //TODO...
        }
    }
}

And helper method:

private static StandardTileData CreateTile(string Name)
{
    StandardTileData initialData = new StandardTileData
    {
        BackgroundImage = new Uri("images/DEFAULT.png", UriKind.Relative),
        Title = Name,
        BackContent = "No updates yet",
        BackTitle = "Mood",
    };
    return initialData;
}

Let’s see what’s new in those methods. First – StandardTileData. It is a new class which defines the behavior of the secondary tile. It enables to define titles, contents and images for both sides of the tile. It also enables setting the count property to front face of the tile.

Note: If back property was not set, the tile will not flip.

Next – creating the tile itself: ShellTile.Create accepts the URI parameter which will serve two purposes: the ID of the tile and the URI within the application to navigate if the tile clicked.

Those parameters also affect the tile notification format sent to the application through Push Notification Server:

Content-Type: text/xml
X-WindowsPhone-Target: token

<?xmlversion="1.0"encoding="utf-8"?>
<wp:Notification xmlns:wp="WPNotification">
  <wp:Tile Id="THE URL">
    <wp:BackgroundImage><background image="" path=""></wp:BackgroundImage>
    <wp:Count><count></wp:Count>
    <wp:Title><title></wp:Title>
    <wp:BackTitle><back side="" title=""></wp:BackTitle>
    <wp:BackContent><back side="" content=""></wp:BackContent>
    <wp:BackBackgroundImage><back side="" background="" image="" path=""></wp:BackBackgroundImage>
  </wp:Tile>
</wp:Notification>

Bold parts are new for Mango.

When the tile arrives to the phone it will be identified by ID (which also serves as relative URI in the app) and will use provided images from application’s content.

Note: if secondary tile already removed (not found) nothing happens, no error thrown.

Note #2: the application doesn’t need to have primary tile on the main screen in order to make secondary tile to work.

Since it is not possible to create two tiles with the same ID, we need to manage the tiles from the application. For this matters ShellTile class provides the collection of ActiveTiles which represent all pinned tiles of the application (including the main tile if pinned by user).

The sample checks the pinned stated for secondary tiles and sets the corresponding checkbox state:

//Check for pinned secondary tiles and update UI
ShellTile toFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("Alex"));
if (null != toFind)
    chkAlex.IsChecked = true;

Same done when the tile need to be removed when unchecking the ckeckbox (after the “//TODO…” in “chkAlex_CheckedUnchecked” function):

ShellTile toFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("Alex"));
toFind.Delete();

This way tiles added and removed from the main screen. See the video of working application below:

Working application

Last feature I want to talk about is known as “deep toast”. It enables to send relative URI to the application and navigate to specific page when TOAST notification clicked by user. In addition I’ll show how to send a local push notification message.

First – the change you have to make for your server side logic to sent deep toast message via push notification server:

Content-Type: text/xml
X-WindowsPhone-Target: toast

<?xmlversion="1.0"encoding="utf-8"?>
<wp:Notification xmlns:wp="WPNotification">
  <wp:Toast>
    <wp:Text1><string></wp:Text1>
    <wp:Text2><string></wp:Text2>
    <wp:Param><THE URL=""></wp:Param>
  </wp:Toast>
</wp:Notification>

Bold line is new for Mango.

In order to create local deep toast I’ll use Background Agent (see part 5 in case you missed it) which will notify the user about mood change.

In the agent class I’ve created string arrays with mood/names:

string[] Names = { "Alex", "Nicole", "Medeya", "Bru" };
string[] Moods = { "anger", "burn", "confused", "cool", "cry", "fire", "grimace", "love",
            "miao", "prettiness", "question", "shout", "slobber", "smile", "spook",
            "startle", "surprise", "sweat", "thirst", "vomit"};
Random rnd = new Random();

When agent awakes I’m creating new ShellToast instance:

protected override void OnInvoke(ScheduledTask task)
{
    if (!isChanceled)
    {
        int nameNum = rnd.Next(Names.Length);
        int moodNum = rnd.Next(Moods.Length);

        ShellToast toast = new ShellToast();
        toast.Title = "Mood Change!";
        toast.Content = Names[nameNum] + " changed mood";
        toast.NavigationUri = new Uri("/MoodInfo.xaml?Name=" + Names[nameNum] + "&Mood=" + Moods[moodNum], UriKind.Relative);
        toast.Show();
    }
    NotifyComplete();
}

The  NavigationUri points to the existing page in my application. Clicking on it takes user into specific page in the app.

image

Note: Due to bug in beta the deep toast feature is not working and will navigate always to the MainPage.xaml regardless to the URI provided. This feature should be fixed after beta.

The sample used in this post hosted here.

This is it… Will be happy to answer more questions.

Stay tuned for more Mango posts to come Smile

Alex

More Posts Next page »