• 在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;
            }
  • 相关阅读:
    《SmartJs系列》屌丝逆袭,华丽转身,解读自定义ScrollBar(一)
    IE6/IE7下,li设置float后,行高变高问题__UL的padding-top Bug
    团队作业
    团队作业
    结对作业
    个人作业
    心得
    css3的自定义字体
    javascript中的call方法
    javascript对象访问
  • 原文地址:https://www.cnblogs.com/malingbo/p/2207646.html
Copyright © 2020-2023  润新知