WPF学习之路(十三)URL

 

URL一般由三个部分组成,协议、资源所在主机地址、资源路径

 

WPF中URL同样有三部分组成:pack、authority(application:| siteoforigin:)、路径

 

资源文件

本地程序集

Uri uri = new Uri("pack://application:,,,/ResourceFile.xaml", UriKind.Absolute);

Uri uri = new Uri("pack://application:,,,/Subfolder/ResourceFile.xaml", UriKind.Absolute);

引用的程序集

Uri uri = new Uri("pack://application:,,,/ReferencedAssembly;component/ResourceFile.xaml", UriKind.Absolute);

Uri uri = new Uri("pack://application:,,,/ReferencedAssembly;component/Subfolder/ResourceFile.xaml", UriKind.Absolute);

Uri uri = new Uri("pack://application:,,,/ReferencedAssembly;v1.0.0.0;component/ResourceFile.xaml", UriKind.Absolute);

 

内容文件

Uri uri = new Uri("pack://application:,,,/ContentFile.xaml", UriKind.Absolute);

Uri uri = new Uri("pack://application:,,,/Subfolder/ContentFile.xaml", UriKind.Absolute);

Uri uri = new Uri("pack://siteoforigin:,,,/SOOFile.xaml", UriKind.Absolute);    源站点文件

Uri uri = new Uri("pack://siteoforigin:,,,/Subfolder/SOOFile.xaml", UriKind.Absolute);

 

相对URL

Uri uri = new Uri("/ResourceFile.xaml", UriKind.Relative);

Uri uri = new Uri("/Subfolder/ResourceFile.xaml", UriKind.Relative);

Uri uri = new Uri("/ReferencedAssembly;component/ResourceFile.xaml", UriKind.Relative);

Uri uri = new Uri("/ReferencedAssembly;component/Subfolder/ResourceFile.xaml", UriKind.Relative);

Uri uri = new Uri("/ContentFile.xaml", UriKind.Relative);

Uri uri = new Uri("/Subfolder/ContentFile.xaml", UriKind.Relative);

 

 

以上内容转载自 http://zhxh1012.blog.163.com/blog/static/140866457201191752652161/

MSDN https://msdn.microsoft.com/zh-cn/library/aa970069(v=vs.110).aspx

 

 

To be continue...

posted on 2015-04-27 09:21  alex_cool  阅读(1707)  评论(0编辑  收藏  举报