xaml中图像源路径的含义是什么? [英] What do image source paths mean in xaml?

查看:113
本文介绍了xaml中图像源路径的含义是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在查看我在Visual Studio中工作的项目的源代码,并且在WPF窗口XAML中路径看起来很奇怪。例如,window元素的icon成员如下所示: Icon =/ ProjectName; component / icons / ProjectName.ico

I'm looking at the source code for the project I'm working on in Visual Studio, and the paths look weird in the WPF window XAML. For example, the icon member of the window element looks like this: Icon="/ProjectName;component/icons/ProjectName.ico"

首先,分号是什么意思?这表明两条可能的路径吗?这没有意义。

First of all, what does the semicolon mean? Does that indicate two possible paths? That doesn't make sense.

我猜 ProjectName;组件表示路径,因为没有<项目中的code>组件文件夹。在我的项目文件夹中, icons / ProjectName.ico 是图标所在的位置。

I'm guessing ProjectName;component represents a path, because there's no component folder in my project. In my project folder, icons/ProjectName.ico is where the icon is.

这是什么意思?

推荐答案

这是资源文件包URI ,没有前缀 pack:// application:,,, ,由XAML Parser自动添加。

That is a Resource File Pack URI, without the prefix pack://application:,,,, which is automatically added by the XAML Parser.

完整的包URI将是

pack://application:,,,/ProjectName;component/icons/ProjectName.ico

并在引用的程序集<$中的 icons 子文件夹中引用名为 ProjectName.ico 的资源文件C $ C>项目名。 ;组件部分将程序集名称与文件路径分开。

and would reference a resource file named ProjectName.ico in an icons subfolder in the referenced assembly ProjectName. The ;component part separates the assembly name from the file path.

如果资源文件位于本地程序集中,你可以省略引用的汇编部分,然后写

If the resource file is in the local assembly, you could omit the referenced assembly part, and write

pack://application:,,,/icons/ProjectName.ico

或在XAML中

/icons/ProjectName.ico

这篇关于xaml中图像源路径的含义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆