Silverlight从程序集中读取xaml文件

时间:2008-04-11 07:46:57  来源:nasa.cnblogs.com  作者:nasa  【背景色 杏仁黄 秋叶褐 胭脂红 芥末绿 天蓝 雪青 灰 银河白

      StreamResourceInfo sri = Application.GetResourceStream(new Uri("HowTo;component/Page.xaml", UriKind.Relative));
            StreamReader sr = new StreamReader(sri.Stream);
            txtReadxml.Text = sr.ReadToEnd();

{1};component/{2}
1为程序集的名字
2为想读取的页面
page.xaml:

<UserControl x:Class="HowTo.Page"
    xmlns="http://schemas.microsoft.com/client/2007" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Width="400" Height="300">
    <Grid x:Name="LayoutRoot" Background="White">
        <TextBlock x:Name="txtReadxml"></TextBlock>
    </Grid>
</UserControl>

Silverlight从程序集中读取xaml文件

这种方法不仅可以读取xaml.  只要是以嵌入资源的形式放在项目中都可以获取.


文章评论

共有 0位网翼网友发表了评论 查看完整内容

推荐信息

     

24小时热门信息