在 WPF 应用程序中使用包 URI 真的很重要吗?

编程入门 行业动态 更新时间:2024-10-11 23:16:08
本文介绍了在 WPF 应用程序中使用包 URI 真的很重要吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我们为什么要使用那些,而不是普通的?

Why should we use those, rather than ordinary ones?

使用它有什么好处:

new Uri("pack://application:,,,/File.xaml");

以上:

new Uri("/File.xaml", UriKind.Relative);

推荐答案

第一个 - 您可以通过在三个逗号后添加程序集名称来使用交叉程序集.因此,您可以创建一个具有通用样式和其他 XAML 优点的共享库,这些库可以在多个程序集之间共享.

The first one - you can use cross-assembly by adding a assembly-name after the three commas. So, you can create a shared library with common styles and other XAML-goodness that can be shared between several assemblies.

语法是这样的:

pack://application:,,,/Common;component/CommonResources.xaml

其中 Common 是程序集的名称,component 之后的所有内容都是该程序集中到映射资源的路径.后者只能在同一个程序集中使用(并且应该是首选).

where Common is the name of the assembly and everything after component is the path inside that assembly to the mapped resource. The latter can only be used inside the same assembly (and should be preferred).

我经常将它用于位于多个模块类型程序集之上的公共程序集中的 ResourceDictionaries.

I use it a lot for ResourceDictionaries residing in a common assembly above several module-type assemblies.

这篇关于在 WPF 应用程序中使用包 URI 真的很重要吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-28 14:57:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1174868.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:真的很   应用程序   WPF   URI

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!