zoukankan      html  css  js  c++  java
  • silverlight读取xml和读取远程文件

                    //读取配置文件
                    XDocument doc = XDocument.Load("config.xml");
                    XElement root = doc.Element("app");
                    baseUrl = root.Element("appurl").Value;

                     //获取远程文件
                     string filePath = "http://www.baidu.com";
                     Uri uri = new Uri(filePath, UriKind.Absolute);
                     WebClient Appclient = new WebClient();//使用WebClient下载config.xml文件,进行异步读取。
                     Appclient.OpenReadAsync(uri);
                     Appclient.OpenReadCompleted += new OpenReadCompletedEventHandler(Appclient_OpenReadCompleted);

             void Appclient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
            {
                Stream stream = e.Result;
                StreamReader reader = new StreamReader(stream);
                string text = reader.ReadToEnd();
                string[] texts = text.Replace(@"\r\n","&").Split('&');
                if (texts != null)
                {
                    for (int i = 0; i < texts.Length; i++)
                    {
                        Paragraph paragraph = new Paragraph() {  LineHeight = 20};
                        Run run = new Run() { Text = texts[i],  FontSize= 12,
                                              FontFamily = new FontFamily("/shendeng.platform.Controls;component/Fonts/simsun.ttc#SimSun")
                        };
                        paragraph.Inlines.Add(run);
                        ZhiNan.Blocks.Add(paragraph);
                    }
                }
            }

           触发HyperlinkButton点击事件
           private HyperlinkButton hlb;
            //    if (hlb != null)
            //    {
            //        HyperlinkButtonAutomationPeer hyperlinkButtonAutomationPeer = new HyperlinkButtonAutomationPeer(hlb);
            //        hyperlinkButtonAutomationPeer.RaiseAutomationEvent(AutomationEvents.InvokePatternOnInvoked);
            //        IInvokeProvider iinvoke = (IInvokeProvider)hyperlinkButtonAutomationPeer;
            //        if (iinvoke != null)
            //        {
            //            iinvoke.Invoke();
            //        }
            //    }

  • 相关阅读:
    struts2重点——ValueStack和OGNL
    struts2基础——请求与响应、获取web资源
    struts2基础——最简单的一个例子
    servlet、filter、listener、interceptor之间的区别和联系
    服务器端组件
    自定义JSTL标签和函数库
    常见前端效果实现
    HTTP Cookie/Session
    获取动态SQL查询语句返回值(sp_executesql)
    WPF数据绑定
  • 原文地址:https://www.cnblogs.com/LYunF/p/2854061.html
Copyright © 2011-2022 走看看