`
wyf
  • 浏览: 424992 次
  • 性别: Icon_minigender_1
  • 来自: 唐山
社区版块
存档分类
最新评论

SilverLight中调用自定义用户控件

阅读更多

1.在aspx页面中切换调用同一个SilverLight项目中的不同用户控件

 

1.1.       方法一

修改SilverLight项目启动文件App.xmlApplication_Startup事件

 private void Application_Startup(object sender, StartupEventArgs e)

        {

            if (!e.InitParams.ContainsKey("InitPage"))

            {

                this.RootVisual = new MainPage();

                return;

            }

            switch (e.InitParams["InitPage"])

            {

                case "SilverlightControl1":

                    this.RootVisual = new SilverlightControl1();

                    break;

                case "SilverlightControl2":

                    this.RootVisual = new SilverlightControl2();

                    break;

                default:

                    this.RootVisual = new MainPage();

                    break;

            }

 

        }



本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/manimanihome/archive/2009/08/29/4498244.aspx

 修改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/Binglang.SilverlightDemo19.xap"/>

                <param name="InitParams" value="InitPage=SilverlightControl1" />

                <param name="onerror" value="onSilverlightError" />

                <param name="background" value="white" />

                <param name="minRuntimeVersion" value="3.0.40624.0" />

                <param name="autoUpgrade" value="true" />

                <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40624.0" style="text-decoration: none;">

                     <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="获取 Microsoft Silverlight" style="border-style: none"/>

                </a>

           </object><iframe id="_sl_historyFrame" style='visibility:hidden;height:0;width:0;border:0px'></iframe></div>



本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/manimanihome/archive/2009/08/29/4498244.aspx

 1.2.      方法二

 

修改SilverLight项目启动文件App.xmlApplication_Startup事件

  private void Application_Startup(object sender, StartupEventArgs e)

        {

            if (!e.InitParams.ContainsKey("InitPage"))

            {

                this.RootVisual = new MainPage();

                return;

            }

 

            Assembly assembly = Assembly.GetExecutingAssembly();

            String rootName = String.Format("Binglang.SilverlightDemo19.{0}", e.InitParams["InitPage"]);

            UIElement rootVisual = assembly.CreateInstance(rootName) as UIElement;

            this.RootVisual = rootVisual;

 

        }



本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/manimanihome/archive/2009/08/29/4498244.aspx

 以上反射取得所需控件,也可以用下面反射代码:

 

 String rootName = String.Format("Binglang.SilverlightDemo19.{0}", e.InitParams["InitPage"]);
 
Type type = Type.GetType(rootName );
  UIElement rootVisual = Activator.CreateInstance(type)  as UIElement;

 this.RootVisual  = (UIElement)this._contentPage;

 

修改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/Binglang.SilverlightDemo19.xap"/>

                <param name="InitParams" value="InitPage=SilverlightControl1" />

                <param name="onerror" value="onSilverlightError" />

                <param name="background" value="white" />

                <param name="minRuntimeVersion" value="3.0.40624.0" />

                <param name="autoUpgrade" value="true" />

                <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40624.0" style="text-decoration: none;">

                     <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="获取 Microsoft Silverlight" style="border-style: none"/>

                </a>

           </object><iframe id="_sl_historyFrame" style='visibility:hidden;height:0;width:0;border:0px'></iframe></div>



本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/manimanihome/archive/2009/08/29/4498244.aspx

 2.调用不同SilverLight项目中的指定控件

 

2.1.建立项目

(1)Binglang.SilverlightDemo20

(2)Binglang.SilverlightDemo20.Web

(3) Binglang.ExternalProject

 

注意:项目Binglang.SilverlightDemo20中需要引用using System.Xml.Linq;

 

假设(1)(3)中各有一个控件,名称都为MainPage.xaml (不一定要相同)

 

分享到:
评论

相关推荐

    庖丁解牛:纵向切入ASP.NET 3.5控件和组件开发技术

    3.8.2 屏蔽基类控件中的属性 52 3.8.3 page.request.browser属性 53 3.8.4 设置控件id规范 53 3.8.5 增强findcontrol功能 54 3.8.6 映射服务端控件值到客户端 55 3.8.7 禁止派生自compositecontrol的控件创建子...

    silverlight 3 控件经典入门学习案例

    案例中的控件全部有源代码示范学习为主。 1.Calendar组件(日历组件) 2.ChildWindow组件(子窗体组件) 3.浮动窗体组件 4.GridSplitter组件 5.TabControl组件 6-7-8.TreeView组件 9.DtarGrid 10.强大的...

    庖丁解牛 纵向切入ASP.NET 3.5控件和组件开发 part1

    第15章 自定义控件设计模式下编程汇总 534 15.1 .net框架对设计时支持 534 15.2 设计时元数据支持 535 15.3 复杂属性序列化 539 15.4 类型转换器 539 15.5 属性编辑器 540 15.6 设计模式可用基类介绍 541 ...

    庖丁解牛 纵向切入ASP.NET 3.5控件和组件开发 part2

    第15章 自定义控件设计模式下编程汇总 534 15.1 .net框架对设计时支持 534 15.2 设计时元数据支持 535 15.3 复杂属性序列化 539 15.4 类型转换器 539 15.5 属性编辑器 540 15.6 设计模式可用基类介绍 541 ...

    Silverlight Loader

    该步就是在HTML或asp:Silverlight控件中加入对SLLoader.xap的调用,并将LoadTarget.xap的名字做为参数传递给SLLoader.xap,以便加载, 可以看出,在建立整个项目的过程中,SLLoader.xap和LoadTarget.xap并不需要打...

    Silverlight2.0功能展示Demo源码

    1、Silverlight(3) - 2.0控件之Border, Button, Calendar, Canvas, CheckBox, ComboBox 介绍 Silverlight 2.0 控件一览:Border, Button, Calendar, Canvas, CheckBox, ComboBox 2、Silverlight(4) - 2.0控件之...

    ASP.NET4高级程序设计第4版 带目录PDF 分卷压缩包 part1

    书中还深入讲述了其他ASP.NET图书遗漏的高级主题,如自定义控件的创建、图像处理、加密等。此外,《ASP.NET 4高级程序设计(第4版)》专门提供了两章的内容来教你如何用Ajax 技术制作快速响应的页面,以及如何使用微软...

    ASP.NET4高级程序设计(第4版) 3/3

    书中还深入讲述了其他ASP.NET图书遗漏的高级主题,如自定义控件的创建、图像处理、加密等。此外,《ASP.NET 4高级程序设计(第4版)》专门提供了两章的内容来教你如何用Ajax 技术制作快速响应的页面,以及如何使用微软...

    基于Silverlight4权限框架

    1. absCommon为自定类库,目前包括日期...3. ABIScontrols为自定义控件项目,包括对数据字典的调用、小图片显示在DROP里等控件 4. ABISCustom.Web目录为web目录,系统完工后仅需要将此目录下文件拷贝在客户的服务器上

    Visual.Basic.2010.&.NET4.高级编程(第6版)-文字版.pdf

    12.3.2 创建用户定义的类型 475 12.3.3 创建存储过程 487 12.3.4 在sql server中使用web服务 493 12.3.5 sql server 2008特性 498 12.4 wcf数据服务 499 12.4.1 rest 499 12.4.2 atom和json 499 ...

    一款非常好的WPF编程宝典2010 源代码

    15.5.2 ItemsControl控件中的 控件模板 388 15.5.3 修改滚动条 390 15.5.4 创建自定义窗口 394 15.5.5 SimpleStyle示例项目 398 15.6 结束语 400 第16章 数据绑定 401 16.1 数据绑定基础 401 16.1.1 绑定到...

    Apress.Pro.WPF.in.C.Sharp.2008.2nd.Edition.Feb.2008

    15.5.2 ItemsControl控件中的 控件模板 388 15.5.3 修改滚动条 390 15.5.4 创建自定义窗口 394 15.5.5 SimpleStyle示例项目 398 15.6 结束语 400 第16章 数据绑定 401 16.1 数据绑定基础 401 16.1.1 绑定到元素的...

    工作流程引擎.包含大量文档2012813

    D:\ccflow\DLL -- 第三方组件中需要调用dll. D:\ccflow\Documents - 文档 D:\ccflow\VisualFlow --bs工作流程引擎前台. D:\ccflow\VisualWorkFlowServices - 流程服务程序. D:\ccflow\VisualFlowWebDesigner - ...

    驰骋工作流引擎源码

    D:\ccflow\DLL -- 第三方组件中需要调用dll. D:\ccflow\Documents - 文档 D:\ccflow\VisualFlow --bs工作流程引擎前台. D:\ccflow\VisualWorkFlowServices - 流程服务程序. D:\ccflow\VisualFlowWebDesigner - ...

Global site tag (gtag.js) - Google Analytics