sliverlight入门指南

sliverlight入门指南,第1张

概述一、服务变换: 如服务为http://superstring/arcgis/services/servies/massl/MapServer变换为 http://superstring/arcgis/rest/services/massl/MapServer。浏览器访问成功会有描述。 对于建过tile的,<esri:ArcGISDynamicMapServiceLayer ID="MyLayer"

一、服务变换:

如服务为http://superstring/arcgis/services/servies/massl/MapServer变换为

http://superstring/arcgis/rest/services/massl/MapServer。浏览器访问成功会有描述。

对于建过tile的,<esri:ArcGISDynamicMapServiceLayer ID="MyLayer"  Url="http://serverapps.esri.com/ArcGIS/rest/services/California/MapServer" /> 应该为

<esri:ArcGISTiledMapServiceLayer ID="MyLayer"
               Url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" />

二、根据控件名寻找控件:

TextBox t = this.Findname("Made_in_China") as TextBox;

三、未出图的可能性:

1)服务不对,参照1解决

2)Extent="118.225,31.327,119.005,31.790"范围错误,参照arcgis map的图的最大范围解决

3)存在载入图片资源路径不对照成

四、动态加载

public partial class Page : UserControl { public Page() { InitializeComponent(); this.Loaded += new RoutedEventHandler(Page_Loaded); } private voID Page_Loaded(object sender,RoutedEventArgs e) { //Silverligh2 提供 XamlReader.Load(string xaml) 片段式 创建xaml。 //命名空间"http://schemas.microsoft.com/clIEnt/2007" 不能少。 string buttonXAML = "<button xmlns='http://schemas.microsoft.com/clIEnt/2007' WIDth=/"60/" Height=/"50/" Content=/"string/" margin=/"10/" Foreground=/"Red/"></button>"; button btnRed = (button)System.windows.Markup.XamlReader.Load(buttonXAML); sp.Children.Add(btnRed); //从文件创建,该文件 的Build Action 为 "Page",与"Resource"类似,被嵌入程序集内 button btn1 = (button)LoadXaml("/LoadXaml;component/btns/btn1.xaml"); sp.Children.Add(btn1); //从文件创建,该文件 的Build Action 为 "Resource",被嵌入程序集内 //注意格式:"/命名空间;component/文件位置" button btn2 = (button)LoadXaml("/LoadXaml;component/btns/btn2.xaml"); sp.Children.Add(btn2); //从文件创建,该文件 的Build Action 为 "Content",仅打包进.xap中,不在任何程序集内 button btn3 = (button)LoadXaml("btns/btn3.xaml"); sp.Children.Add(btn3); //从错误的文件创建,最终生成的是默认的对象 button btnDef = (button)LoadXaml("btns/btn4.xaml"); sp.Children.Add(btnDef); } /// <summary> /// 从xaml文件中 创建 xaml对象 /// </summary> /// <param name="file">xaml文件的"地址"</param> /// <returns>返回xaml文件定义的对象</returns> public static object LoadXaml(string file) { Uri fileUri = new Uri(file,UriKind.relative); System.windows.Resources.StreamResourceInfo streamInfo = System.windows.Application.GetResourceStream(fileUri); if ((streamInfo != null) && (streamInfo.Stream != null)) { using (System.IO.StreamReader reader = new System.IO.StreamReader(streamInfo.Stream)) { return System.windows.Markup.XamlReader.Load(reader.ReadToEnd()); } } //若文件不存在,则返回默认创建的对象 return CreateDefaultObject(); } //创建默认对象,以一个简单的button为例 public static object CreateDefaultObject() { button btn = new button(); btn.WIDth = 60; btn.Height = 50; btn.Foreground = new SolIDcolorBrush(colors.Blue); btn.Content = "Default"; return btn; } }

五、资源文件:

i、直接把资源文件放在ClIEnBin文件目录下。此时引用要加入反斜杠。如 Source="/p.jpg"   ii、把资源文件放在与page.xaml同目录下,此时我们有两个选择:     一是把资源文件属性中的“Build Action”栏即:"生成 *** 作"设置为"Resource"。此时资源打包在程序集,此时引用不用加入反斜杠。如 Source="p.jpg"     二是把资源文件属性中的“Build Action”栏即:"生成 *** 作"设置为"Content"。此时资源打包在.xap压缩包中,引时引用该文件则需要以反斜杠开头。如 Source="/p.jpg"   那么,上述放法在性能上有什么区别呢:   因为,不以反斜杠开头的图片资源是嵌入到Silverlight程序中,xap文件直接下载到客户端,所以当数据量较大时,不以反斜杠开头的方式加载程序的时间就过长。   以"/"开头自然就没上述问题,但是,以反斜杠开头的话,在xaml中设计预览看不到,只有程序运行才可以看到。

总结

以上是内存溢出为你收集整理的sliverlight入门指南全部内容,希望文章能够帮你解决sliverlight入门指南所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1041091.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存