SilverBullet #4 – System.Windows.ApplicationIdentity

silverbullet I’d like to provide you with a SilverBullet™, a small snippet of Silverlight, a class or namespace hidden in the silverlight .NET framework, to help you out in times of need. It’s not to learn, but something to keep in your pocket. Just remember it’s there and you’re safe.

One of the great new features of Silverlight 3 is the so called “Out of Browser” support. This means you can run your application without the browser, but still using the browser secure sandbox. The ApplicationIdentity class can be used to provide some extra information about your application when running outside the browser. The ApplicationIdentity class is primarily used in the AppManifest.xaml file in which information about the application is stored, but the identity information can be read from code.

When you look at this file in a new Silverlight 3 project, the ApplicationIdentity part is commented. Uncommenting this section will enable Out of Browser support for your application.

The ApplicationIdentity class provides four read-only static dependency properties.

  • Blurb               Contains a short description of the application
  • ShortName    Contains a short version of the application title
  • Title                 Contains the longer version of the application title
  • Icons               Contains a list of references to images used as Icons in different sizes

The Blurb, ShortName and Title properties are regular strings and can be used like any other strings in xaml.

The Icons property is of type IconCollection, which is a collections of icons.  An Icon has two properties, Source and Size. Source holds the path to a .PNG file of the icon. Size is a string representation of the size, “16x16” for example.

Here’s an example of how the ApplicationIdentity class is used in the AppManifest.xaml file.

<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment" ... > <Deployment.Parts> ... </Deployment.Parts>

<Deployment.ApplicationIdentity> <ApplicationIdentity ShortName="Out of Browser Silverlight Application" Title="SilverBullet #4 - Test App"> <ApplicationIdentity.Blurb> A demo application explaining Application Identity when running outside of the browser. </ApplicationIdentity.Blurb> <ApplicationIdentity.Icons> <Icon Size="256x256">Favorites.png</Icon> </ApplicationIdentity.Icons> </ApplicationIdentity> </Deployment.ApplicationIdentity>
</Deployment>

You can read the ApplicationIdentity dependency properties from code by using the class directly by getting the values like:

string Blurb = GetValue(ApplicationIdentity.BlurbProperty) as string; string Title = GetValue(ApplicationIdentity.TitleProperty) as string; IconCollection icons = GetValue(ApplicationIdentity.IconsProperty) as IconCollection; aRandomImage.Source = new BitmapImage(new Uri(icons[0].Source));

>>
>
>
This article is part of the GWB Archives. Original Author: Timmy Kokke

New on Geeks with Blogs

  • We Won The One Award I Actually Care About

    Full Scale made the Inc. 5000 for the fifth year straight, the 12th listing across my three companies. Here is why the one award you cannot buy is worth stopping for.

  • Your Customers Build the Features Now

    I let a tool I liked sit dead for a year rather than build the features I wanted. An MCP server meant I never had to, and your customers can do the same to your product.

  • Get the Size of a Directory in Linux the Easy Way

    du -sh for the quick answer, ncdu for the cleanup, df for the disk itself: every command for checking directory size in Linux, plus why du and df never agree.

  • Vim Search and Replace: The Ultimate Guide

    One :%s command replaces every match in a file before a find dialog would even open. The Vim substitute patterns worth the muscle memory: flags, ranges, capture groups, and multi-file edits.