zoukankan      html  css  js  c++  java
  • 在silverlight中实现对控件的deepcopy

    使用XamlReader.Load(string)方法实现
    步骤:
     

    Xamlreader.load的用法:

    1,在界面中拖拽自定义控件,设置布局和位置;

    2,拷贝自定义控件代码,放入另外的xml文件中,在标记头加上命名空间和程序集声明,删除不必要的属性。这里要注意

     xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"
     xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" 
    一定要有

    3,使用xamlreader.load加载

    public static FillSymbol loadfillsymbol()
            {
                string strxaml = "<symbol:FillSymbol xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"  xmlns:arcsample=\"clr-namespace:arcgissampleApp.MAP;assembly=arcgissampleApp\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" xmlns:symbol=\"clr-namespace:ESRI.ArcGIS.Client.Symbols;assembly=ESRI.ArcGIS.Client\" Fill=\"Red\" BorderThickness=\"2\">" +
                    "<symbol:FillSymbol.ControlTemplate>"+
                        "<ControlTemplate>"+
                            "<Grid x:Name=\"RootElement\">"+
                                "<Grid.RowDefinitions>"+
                                    "<RowDefinition Height=\"100\"/>"+
                                    "<RowDefinition/>"+
                                "</Grid.RowDefinitions>"+
                                "<Grid.ColumnDefinitions>"+
                                    "<ColumnDefinition Width=\"100\"/>"+
                                    "<ColumnDefinition/>"+
                                "</Grid.ColumnDefinitions>"+
                                "<Path Grid.RowSpan=\"2\" Grid.ColumnSpan=\"2\" x:Name=\"Element\" Fill=\"{Binding Attributes[COLOR]}\" Stroke=\"Red\" StrokeThickness=\"1\" />"+
                                "<TextBlock Grid.RowSpan=\"2\" Grid.ColumnSpan=\"2\" Text=\"{Binding Attributes[NAME]}\" FontSize=\"20\" Foreground=\"Black\" HorizontalAlignment=\"Center\" VerticalAlignment=\"Center\">"+
                                "</TextBlock>"+
                                "<arcsample:SilverlightControl2 Grid.RowSpan=\"2\" Grid.ColumnSpan=\"2\" Margin=\"-100,-50,0,0\"  Grid.Row=\"0\" Grid.Column=\"0\" x:Name=\"sc2\" SelectedGroupM=\"{Binding Attributes[GGG]}\" HorizontalAlignment=\"Center\" VerticalAlignment=\"Center\"/>" +
                            "</Grid>"+
                        "</ControlTemplate>"+
                    "</symbol:FillSymbol.ControlTemplate></symbol:FillSymbol>";
                FillSymbol symbol = XamlReader.Load(strxaml) as FillSymbol;
                return symbol;
            }
  • 相关阅读:
    微信小程序 改变radio(单选钮)默认大小
    iframe自适应高度
    微信小程序获得unionid
    Git的使用--如何将本地项目上传到Github
    一个服务器的Apache2.4.6配置多个域名
    CENTOS安装ElasticSearch
    CentOS7 64位下MySQL5.7安装与配置(YUM)
    在CentOS 7上搭建WordPress
    CentOS7安装MySQL
    Intellij idea 快捷键大全
  • 原文地址:https://www.cnblogs.com/malingbo/p/2207646.html
Copyright © 2011-2022 走看看