假如在 SilverlightApplication6 工程中添加一个文件夹 Content ,下面放置一个 mxh.txt 文件和 mxh.jpg
的照片,文件内容随便写。在“解决方案浏览器”的文件属性中,设置“Build Action”为“Content”;“Copy to Output
Directory”属性设置为“Do not copy”。
在 xaml 文件中输入:
XAML
代码
<!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><UserControl x:Class="SilverlightApplication6.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="800"
Height="600">
<Grid
x:Name="LayoutRoot" Background="White">
<Canvas
Width="800"
Height="600">
<TextBox
x:Name="TextBoxName" Height="30"
Canvas.Top="10"></TextBox>
<Image
x:Name="ImageNameIncude" Canvas.Top="60"
Height="200"></Image>
<Image
x:Name="ImageNameEmbed" Canvas.Top="260"
Height="100"></Image>
</Canvas>
</Grid>
</UserControl>
xaml.cs 内容输入:
C#
代码
<!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
-->using System;
using
System.Windows;
using System.Windows.Media.Imaging;
using
System.Windows.Controls;
using
System.IO;
using System.Windows.Resources;
namespace
SilverlightApplication6
{
public
partial class
MainPage : UserControl
{
public
MainPage()
{
InitializeComponent();
//
读取文字
StreamResourceInfo r =
Application.GetResourceStream(new
Uri("Content/mxh.txt",
UriKind.Relative));
StreamReader sr = new
StreamReader(r.Stream);
TextBoxName.Text =
sr.ReadToEnd();
sr.Dispose();
//显示 Build
Action 为 Content图片
r =
Application.GetResourceStream(new
Uri("Content/mxh.jpg",
UriKind.Relative));
BitmapImage bmp1 = new
BitmapImage();
bmp1.SetSource(r.Stream);
ImageNameIncude.Source
=
bmp1;
//显示 Build Action 为 Resource图片
r
=
Application.GetResourceStream(new
Uri("SilverlightApplication6;component/Content/mxh2.jpg",
UriKind.Relative));
BitmapImage bmp2 = new
BitmapImage();
bmp2.SetSource(r.Stream);
ImageNameEmbed.Source
=
bmp2;
}
}
}
按F5进行编译预览,即可在 TextBox 中看到 mxh.txt文件的内容和显示孟宪会的照片。
注意:分隔符“;component/”是必须的。
分享到:
相关推荐
clientBin silverlight xap文件
1.在现有SLLoader.xap项目中使用SilverlightLoader:先下载SilverlightLoader压缩包,从下载的Release中找到SilverlightLoader.cs,并将其添加到SLLoader.xap项目中,具体实现方法:在SLLoader.xap项目中右键添加已...
进来学习cocos2dx,为了研究对wp8的支持,将 cocos2dxForWp8中自带的样例工程打成了一个支持wp8安装的安装包,tests.xap,手机解锁的同学可以下来装手机上,体验一下cocos2dx对WP8的支持
WP7Booster.xapWP7Booster.xapWP7Booster.xap
介绍Silverlight与wcf异步调用,修改xap文件内的配置。内附源代码实例。
.archivetempwp8启动画面模拟-CHS_v1.0.0.0.xap
国外著名Silverlight网站相应的XAP文件,效果十分绚丽,可以用作参考素材。
SamWP8_Tools_Debug_ARM.xap
诺基亚导航_Nokia+Drive+-+v1000+-+Unlimited.xap
XAP包(注:XAP文件是Silverlight 2应用程序编译打包后的一个文件,包括了Silverlight 2应用程序所需的一切文件,如程序集、资源文件等) 查看和导出XAP包内容; 查看和导出程序集和资源文件; 查看.NET类型和...
将Silverlight上传工具集成到网页文件中需要进行简单的配置,看 如下各项参数作用。 配置: MaxFileSizeKB: 文件大小 KBs. MaxUploads: 同时上传文件的最大数量 FileFilter: 文件类型过滤, 假如只使用jpeg文件: ...
解决lumia1020手机中无专业拍摄pp
手机号码定位 Windows手机适用 Microsoft.Phone.Controls.Toolkit.dll自己慢慢琢磨
可在桌面直接运行XAP文件 无需IE或VS编译环境 亲测好用
诺基亚lumia 存储管理器
Silverlight多文件(大文件)上传项目源码 一个免费的SL多文件上传,支持大文件上传 Features(特色): - Select multiple files to upload (选择多文件上传) - Upload multiple files at the same time ...
XAP文件的ClientBin在一个文件夹中。您不必这样做,如果你不这样做,您将需要调整 从下面的相对路径(即没有..需要的例子显示在您的网址\)。 要使用单文件播放器,只需通过以下初始化params到您的Silverlight对象...
免费的公共 wifi 连接工具
这是花了2天的时间做的一个小工具,还是挺好用的,所以先跟大家分享一下,这个是一个配置SILVERLIGHT里.xap文件IP的一个小工具,注意 放在clintbin外面
jQuery的Silverlight插件,以jQuery的方式创建SL. $(function() { $("#silverlightControlHost").silverlight({ source: 'ClientBin/SilverlightApplication1.xap', height: '100%' }); });