前文对原理做了简要分析,该篇将针对做部分应用。
总述
在Silverlight 3正式版发布之前,开启该功能,需要修改Properties文件夹下的AppManifest.xml文件。
代码如下:
- <Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
- <Deployment.Parts>
- </Deployment.Parts>
- <Deployment.OutOfBrowserSettings>
- <OutOfBrowserSettings
- ShortName="oob">
- <OutOfBrowserSettings.WindowSettings>
- <WindowSettings Title="I support OOB" />
- </OutOfBrowserSettings.WindowSettings>
- <OutOfBrowserSettings.Blurb>
- Saving your Silverlight offline.
- </OutOfBrowserSettings.Blurb>
- </OutOfBrowserSettings>
- </Deployment.OutOfBrowserSettings>
- </Deployment>
可设置的OutOfBrowerSettings属性。
ShortName – 程序在桌面或开始菜单中的显示名称。
Title – 程序运行时标题栏的现实内容。
Blurb – 程序的备注内容。
当F5运行该程序时,可以看到下面的菜单:
选择第二项。选择添加到开始菜单或者同时安装到桌面,默认选择开始菜单:
移除离线程序也很简单。右键单击运行中的离线程序,选择第二项:
在Silverlight离线程序中同样可以自定义桌面图标,开始菜单图标等。需要创建四个不同尺寸的PNG文件,16X16、32X32、64X64、128X128。把它们添加到项目中并指定路径,设置图标文件的Build Action的属性为Content。
- <OutOfBrowserSettings.Icons>
- <Icon Size="16,16">Images/sl16.png</Icon>
- <Icon Size="32,32">Images/sl32.png</Icon>
- <Icon Size="64,64">Images/sl64.png</Icon>
- <Icon Size="128,128">Images/sl128.png</Icon>
- </OutOfBrowserSettings.Icons>
- </OutOfBrowserSettings.Icons>
现在就可以得到自定义图标了。
完整的AppManifest.xml文件。
- <Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- EntryPointAssembly="silverlight-oob"
- EntryPointType="silverlight-oob.App"
- >
- <Deployment.Parts>
- </Deployment.Parts>
- <Deployment.OutOfBrowserSettings>
- <OutOfBrowserSettings
- ShortName="silverlight-oob">
- <OutOfBrowserSettings.WindowSettings>
- <WindowSettings Title="I support OOB" />
- </OutOfBrowserSettings.WindowSettings>
- <OutOfBrowserSettings.Blurb>
- Saving your silverlight offline
- </OutOfBrowserSettings.Blurb>
- <OutOfBrowserSettings.Icons>
- <Icon Size="16,16">Images/sl16.png</Icon>
- <Icon Size="32,32">Images/sl32.png</Icon>
- <Icon Size="48,48">Images/sl48.png</Icon>
- <Icon Size="128,128">Images/sl128.png</Icon>
- </OutOfBrowserSettings.Icons>
- </OutOfBrowserSettings>
- </Deployment.OutOfBrowserSettings>
- </Deployment>
Silverlight 3 的OOB并不支持对窗体的修改。
在Silverlight 3 以及 Expression Studio 3 (Expression Blend 3)正式发布时,这个OOB设置方式进行了简化。无需设置Appmanifest.xml,你可以在Properties看到OutOfBrowserSettings.xml文件。
- <?xml version="1.0" encoding="utf-8" ?>
- <OutOfBrowserSettings ShortName="silverlight-oob" EnableGPUAcceleration="True">
- <OutOfBrowserSettings.Blurb>
- A short description of the application.
- </OutOfBrowserSettings.Blurb>
- <OutOfBrowserSettings.WindowSettings>
- <WindowSettings Height="600" Width="800" Title="silverlight-oob" />
- </OutOfBrowserSettings.WindowSettings>
- </OutOfBrowserSettings>
在Expression Blend 3中,选择Project->Silverlight Projects Options->Enable Application Outside Browser。
Demo
Popularity: 8% [?]





[...] Silverlight 3 OOB http://www.mdong.org/?p=828 http://www.mdong.org/?p=836 [...]