Silverlight 读取配置文件
1.ExtranetLink.xml
<?xml version="1.0" encoding="utf-8" ?>
<menus>
<menu Header="水利综合网">
<extranet LinkName="百度网" LinkAdd="http://www.baidu.com"/>
<extranet LinkName="度网线" LinkAdd="http://www.baidu.com"/>
<extranet LinkName="计算机信息化" LinkAdd="http://www.baidu.com"/>
<extranet LinkName="silverlight委员会" LinkAdd="http://www.baidu.com"/>
<extranet LinkName="中央气象局" LinkAdd="http://www.baidu.com"/>
<extranet LinkName="联合国" LinkAdd="http://www.baidu.com"/>
</menu>
<menu Header="各省市天气网">
<extranet LinkName="中央气象局" LinkAdd="http://www.baidu.com"/>
<extranet LinkName="河北" LinkAdd="http://www.baidu.com"/>
<extranet LinkName="北京" LinkAdd="http://www.baidu.com"/>
<extranet LinkName="添加" LinkAdd="http://www.baidu.com"/>
<extranet LinkName="修改" LinkAdd="http://www.baidu.com"/>
<extranet LinkName="百度网盘" LinkAdd="http://www.baidu.com"/>
</menu>
</menus>
2.读取xml文件
private void getXmlDataTask_BeforeStart(object sender, EventArgs e)
{
Task task = sender as Task;
task.MethodName = "ExtranetLink.xml";
task.ReturnType = typeof(String);
}
3.处理文件
private void getXmlDataTaskCallBack(Response response)
{
tabConExtranet.Items.Clear();
XDocument document = XmlParseHelper.XmlParse(response.DataString);
this.Dispatcher.BeginInvoke(() =>
{
IEnumerable<XElement> elements = document.Descendants(XName.Get("menu"));
foreach (XElement parent in elements)
{
TabItem tabItem = new TabItem();
tabItem.Header = parent.Attribute(XName.Get("Header")).Value;
tabItem.Style = App.Current.Resources["tabItemStyle"] as Style;
StackPanel sp = new StackPanel();
tabItem.Content = sp;
sp.Orientation = Orientation.Horizontal;
IEnumerable<XElement> childs = parent.Descendants(XName.Get("extranet"));
foreach (XElement child in childs)
{
HyperlinkButton hyper = new HyperlinkButton();
hyper.TargetName = "_blank";
hyper.Content = string.Concat("", child.Attribute(XName.Get("LinkName")).Value);
hyper.NavigateUri = new Uri(child.Attribute(XName.Get("LinkAdd")).Value);
hyper.Style = App.Current.Resources["hyperlinkStyle"] as Style;
sp.Children.Add(hyper);
}
tabConExtranet.Items.Add(tabItem);
}
});
}
Silverlight 读取配置文件的更多相关文章
- 【无私分享:ASP.NET CORE 项目实战(第八章)】读取配置文件(二) 读取自定义配置文件
目录索引 [无私分享:ASP.NET CORE 项目实战]目录索引 简介 我们在 读取配置文件(一) appsettings.json 中介绍了,如何读取appsettings.json. 但随之产生 ...
- 解决IntelliJ IDEA无法读取配置文件的问题
解决IntelliJ IDEA无法读取配置文件的问题 最近在学Mybatis,按照视频的讲解在项目的某个包里建立配置文件,然后读取配置文件,但是一直提示异常. 读取配置文件的为官方代码: String ...
- java-工具类-读取配置文件
java读取配置文件,当发现文件被修改后则重新加载 package com.zg.config; import java.io.File; import java.io.FileInputStream ...
- java 4种方式读取配置文件 + 修改配置文件
版权声明:本文为博主原创文章,未经博主允许不得转载. 目录(?)[-] 方式一采用ServletContext读取读取配置文件的realpath然后通过文件流读取出来 方式二采用ResourceB ...
- 在IIS Express中调试时无法读取配置文件 错误
在IIS Express中调试代码时,如果出现"无法读取配置文件"的问题(如图),这种情况是IIS Express的"applicationhost.config&quo ...
- ASP.NET Core开发-读取配置文件Configuration
ASP.NET Core 是如何读取配置文件,今天我们来学习. ASP.NET Core的配置系统已经和之前版本的ASP.NET有所不同了,之前是依赖于System.Configuration和XML ...
- Java 利用 ByteArrayOutputStream 和 ByteArrayInputStream 避免重复读取配置文件
最近参与了github上的一个开源项目 Mycat,是一个mysql的分库分表的中间件.发现其中读取配置文件的代码,存在频繁多次重复打开,读取,关闭的问题,代码写的很初级,稍微看过一些框架源码的人,是 ...
- Python+Selenium进行UI自动化测试项目中,常用的小技巧2:读取配置文件(configparser,.ini文件)
在自动化测试项目中,可能会碰到一些经常使用的但 很少变化的配置信息,下面就来介绍使用configparser来读取配置信息config.ini 读取的信息(config.ini)如下: [config ...
- win7 web开发遇到的问题-由于权限不足而无法读取配置文件,无法访问请求的页面
错误一: HTTP Error 500.19 - Internal Server Error配置错误: 不能在此路径中使用此配置节.如果在父级别上锁定了该节,便会出现这种情况.锁定是默认设置的 (ov ...
随机推荐
- console,和自己定义事件
console.log这个指令是在浏览器控制台输出日志,用来调试程序 跟alert 类似 但不像alert那样会打断程序.
- node在安装完成后,出现node不是内部或外部命令
node在安装完成后,查看node版本 node -v出现"node不是内部或外部命令"郁闷. 各种搜索之后,处理好了问题了. 一张图解决问题.
- 查看sql server数据库文件信息
--drop table #dbfiles --deallocate cursor1 ------ declare cursor1 cursor for SELECT name from sys.da ...
- [POJ 2443] Set Operation (bitset)
题目链接:http://poj.org/problem?id=2443 题目大意:给你N个集合,每个集合里有若干个数.M个查询,每个查询有a,b两个数.问是否存在一个集合同时包含a,b这两个数.若存在 ...
- [ZOJ 1002] Fire Net (简单地图搜索)
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1002 题目大意: 给你一个n*n的地图,地图上的空白部分可以放棋 ...
- IO/NIO
1.转换流,Buffered BufferedWriter out=new BufferedWriter(new OutputStreamWriter(System.out)); BufferedRe ...
- (转)C#picturebox控件使用
PictureBox是C#常用图片空间,本文是学习中搜集网络资料的一些整理和记录 1,PictureBox加载图片 using System.Drawing; //方式1,从图片文件载入 //下面的路 ...
- HttpClient + ASP.NET Web API, WCF之外的另一个选择
WCF的野心造成了它的庞大复杂,HTTP的单纯造就了它的简单优美.为了实现分布式Web应用,我们不得不将两者凑合在一起 —— WCF服务以HTTP绑定宿主于IIS. 于是有了让人晕头转向的配置.让人郁 ...
- SmartWiki开发日记之Laravel缓存扩展
SmartWiki简介请阅读: http://www.cnblogs.com/lifeil/p/6113323.html 因为SmartWiki的演示站点部署在阿里云上,阿里云有一个128M免费的Me ...
- Android开发-API指南-<uses-feature>
<uses-feature> 英文原文:http://developer.android.com/guide/topics/manifest/uses-feature-element.ht ...