Silverlight 3 OOB (2)

August 29th, 2009 § 1

Silverlight 3 OOB (1)

前文对原理做了简要分析,该篇将针对做部分应用。

总述

在Silverlight 3正式版发布之前,开启该功能,需要修改Properties文件夹下的AppManifest.xml文件。

代码如下:

  1. <Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
  2.     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  3.     <Deployment.Parts>
  4.     </Deployment.Parts>
  5.      <Deployment.OutOfBrowserSettings> 
  6.     <OutOfBrowserSettings 
  7.       ShortName="oob"> 
  8.       <OutOfBrowserSettings.WindowSettings> 
  9.         <WindowSettings Title="I support OOB" /> 
  10.       </OutOfBrowserSettings.WindowSettings> 
  11.       <OutOfBrowserSettings.Blurb> 
  12.         Saving your Silverlight offline. 
  13.       </OutOfBrowserSettings.Blurb>
  14.     </OutOfBrowserSettings> 
  15.   </Deployment.OutOfBrowserSettings> 
  16. </Deployment>

可设置的OutOfBrowerSettings属性。

ShortName – 程序在桌面或开始菜单中的显示名称。
Title – 程序运行时标题栏的现实内容。
Blurb – 程序的备注内容。

当F5运行该程序时,可以看到下面的菜单:

选择第二项。选择添加到开始菜单或者同时安装到桌面,默认选择开始菜单:

移除离线程序也很简单。右键单击运行中的离线程序,选择第二项:

silverlight-oob-3

在Silverlight离线程序中同样可以自定义桌面图标,开始菜单图标等。需要创建四个不同尺寸的PNG文件,16X16、32X32、64X64、128X128。把它们添加到项目中并指定路径,设置图标文件的Build Action的属性为Content。

  1. <OutOfBrowserSettings.Icons> 
  2.         <Icon Size="16,16">Images/sl16.png</Icon> 
  3.         <Icon Size="32,32">Images/sl32.png</Icon> 
  4.         <Icon Size="64,64">Images/sl64.png</Icon> 
  5.         <Icon Size="128,128">Images/sl128.png</Icon> 
  6.       </OutOfBrowserSettings.Icons> 
  7. </OutOfBrowserSettings.Icons>

现在就可以得到自定义图标了。

完整的AppManifest.xml文件。

  1. <Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
  2.     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3.       EntryPointAssembly="silverlight-oob" 
  4.   EntryPointType="silverlight-oob.App" 
  5. >
  6.     <Deployment.Parts>
  7.     </Deployment.Parts>
  8.      <Deployment.OutOfBrowserSettings> 
  9.     <OutOfBrowserSettings 
  10.       ShortName="silverlight-oob"> 
  11.       <OutOfBrowserSettings.WindowSettings> 
  12.         <WindowSettings Title="I support OOB" /> 
  13.       </OutOfBrowserSettings.WindowSettings> 
  14.       <OutOfBrowserSettings.Blurb> 
  15.         Saving your silverlight offline 
  16.       </OutOfBrowserSettings.Blurb>
  17.         <OutOfBrowserSettings.Icons> 
  18.         <Icon Size="16,16">Images/sl16.png</Icon> 
  19.         <Icon Size="32,32">Images/sl32.png</Icon> 
  20.         <Icon Size="48,48">Images/sl48.png</Icon> 
  21.         <Icon Size="128,128">Images/sl128.png</Icon> 
  22.       </OutOfBrowserSettings.Icons> 
  23.     </OutOfBrowserSettings> 
  24.   </Deployment.OutOfBrowserSettings> 
  25. </Deployment>

Silverlight 3 的OOB并不支持对窗体的修改。

在Silverlight 3 以及 Expression Studio 3 (Expression Blend 3)正式发布时,这个OOB设置方式进行了简化。无需设置Appmanifest.xml,你可以在Properties看到OutOfBrowserSettings.xml文件。

  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <OutOfBrowserSettings ShortName="silverlight-oob" EnableGPUAcceleration="True">
  3.  
  4.     <OutOfBrowserSettings.Blurb>
  5.         A short description of the application.
  6.     </OutOfBrowserSettings.Blurb>
  7.     <OutOfBrowserSettings.WindowSettings>
  8.         <WindowSettings Height="600" Width="800" Title="silverlight-oob" />
  9.     </OutOfBrowserSettings.WindowSettings>
  10. </OutOfBrowserSettings>

在Expression Blend 3中,选择Project->Silverlight Projects Options->Enable Application Outside Browser。

Demo

联系人管理器(由微软提供)

Popularity: 8% [?]

RELATED POSTS

Tagged: , ,

§ One Response to “Silverlight 3 OOB (2)”

What's this?

You are currently reading Silverlight 3 OOB (2) at Mdong·s Space (小气的神).

meta

Switch to our mobile site