• VS2010 Silverlight学习——启动xaml方式


    参考资料:http://www.cnblogs.com/yaoge/category/244456.html
    工具:Visual Studio 2010,Silverlight 3.0

    目前知道的就2种方式。
    1、直接在App.xaml.cs文件里修改当前启动的xaml
        private void Application_Startup(object sender, StartupEventArgs e)
            {
                //SilverlightControl1是新建的xaml文件名称
                this.RootVisual = new SilverlightControl1();//new MainPage();
           }

    2、在.html页面或.aspx页面里添加启动参数,然后在App.xaml.cs获取启动参数,根据不同的参数运行不同的xaml文件。
         如下:
         在.html页面或.aspx页面添加红色字体部分:
        <div id="silverlightControlHost">
            <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
              <param name="source" value="ClientBin/Video.xap"/>
              <param name="onError" value="onSilverlightError" />
              <param name="background" value="white" />
              <param name="minRuntimeVersion" value="3.0.40818.0" />
              <param name="autoUpgrade" value="true" />
              <param name="initParams" value="StartParm=Grid" />
              <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40818.0" style="text-decoration:none">
                   <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="获取 Microsoft Silverlight" style="border-style:none"/>
              </a>
            </object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;0px;border:0px"></iframe></div>
        在App.xaml.cs文件里获取参数:
              private void Application_Startup(object sender, StartupEventArgs e)
            {
                string start = "StartParm"; //对应.html页面或.aspx页面的参数里,value对应表达式的左边StartParm
                if (!e.InitParams.ContainsKey(start))//如果找不到对应的参数,则返回一个默认启动项
                    this.RootVisual = new MainPage();
                else
                {
                    switch (e.InitParams[start]) //根据参数不同启动不同xaml
                    {
                        case "Ellipse":
                            this.RootVisual = new GridExam();
                            break;
                        case "Grid": //此例中传进的StartParm=Grid,因此将启动名称为SilverlightControl1的xaml文件
                            this.RootVisual = new SilverlightControl1();
                            break;
                        case "Rect":
                            this.RootVisual = new RectExam();
                            break;
                        case "Full":
                            this.RootVisual = new Fullscreen();
                            break;
                        default:
                            this.RootVisual = new MainPage();
                            break;
                    }
                }
            }
    ============================================================================== 青春匆匆,很多人都有自己的座右铭,鞭策自己前进,当没看到座右铭的时候又忘了自己要干什么,就这样天天立志,志天天立,最终还是那个初出茅庐的小菜鸟。从现在开始,慢慢去改掉懒惰的习惯。慢慢去加强学习,直到慢慢成功。==============================================================================
  • 相关阅读:
    贝云cms内容管理系统(thinkphp5.0开源cms管理系统)
    NGINX.conf配置文件支持pathinfo
    阿里云视频直播PHPSDK接入教程
    如何在Nginx下配置PHP程序环境
    tomcat 内存参数优化示例
    12组免费的CSS3按钮强力推荐 狼人:
    9款jQuery插件为你的网站增加亮点 狼人:
    TUP第11期:腾讯、豆瓣精英实例诠释互联网研发之道 狼人:
    【TUP第11期】腾讯黄朝兴:浅谈客户端架构 狼人:
    Linus Torvalds:回顾Linux20年 狼人:
  • 原文地址:https://www.cnblogs.com/zlzly/p/2060135.html
Copyright © 2020-2023  润新知