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 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, “16×16” 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.Source));
Tags van Technorati: Silverlight
|Share this post :|