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;
            }
  • 相关阅读:
    c# 扩展方法奇思妙用
    AnkhSVN的自动加锁
    C#数组学习
    同一IP下多端口网站共享cookie的问题
    瞎子摸象销售开票(一)
    瞎子摸象年结
    配置WSS3.0搜索功能的步骤
    瞎子摸象销售开票(二)
    瞎子摸象汇兑损益
    ajax+php鼠标拖动层至任意位置并实时保存
  • 原文地址:https://www.cnblogs.com/malingbo/p/2207646.html
Copyright © 2011-2022 走看看