• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
jasmin_xm
博客园    首页    新随笔    联系   管理    订阅  订阅

Silverlight学习笔记(2)-安装Silverlight到本地

OutOfBrowser.xaml

<Button x:Name="button" Click="button_Click" Width=100 Height=30></Button>

 

OutOfBrowser.xaml.cs

public OutOfBrowser()

{

InitializeComponent();

this.Loaded+=new RoutedEventHandler(OutOfBrowser_Loaded);

}

 

void OutOfBrowser_Loaded(object sender,RoutedEventArgs e)

{

InitButton();

App.Current.InstallStateChanged+=new EventHandler(Current_InstallStateChanged);

}

 

void Current_InstallStateChanged(object sender,EventArgs e)

{

InitButton();

}

 

private void button_Click(object sender,RoutedEventArgs e)

{

if(!App.Current.IsRunningOutOfBrowser&& App.Current.InstallState==InstallState.NotInstalled)

       App.Current.Install();

else

      MessageBox.Show("请右键卸载!");

}

 

 

private void InitButton()

{

         if(App.Current.IsRunningOutOfBrowser)

        button.Content=”卸载”;

else

        button.Content=”安装”;

}

右键单击解决方案中的Properties,选择打开,在打开的菜单中选择Silverlight,选中允许在浏览器外运行应用程序,然后单击浏览器外设置按钮,在打开的窗口中设置安装后要显示的窗口标题,高度和宽度,以及快捷名称和下载说明,设置完成后保存一下,会看到在Properties中生成了一个OutOfBrowserSettings.xml文件,文件中会显示刚才我们配置的一些信息。

然后运行就可以安装了!

posted @ 2010-03-23 16:52  jasmin  阅读(693)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3