惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

W
WeLiveSecurity
The Last Watchdog
The Last Watchdog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
G
Google Developers Blog
博客园 - 叶小钗
雷峰网
雷峰网
人人都是产品经理
人人都是产品经理
博客园_首页
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 三生石上(FineUI控件)
Help Net Security
Help Net Security
Cloudbric
Cloudbric
AI
AI
N
News | PayPal Newsroom
博客园 - 聂微东
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 【当耐特】
Forbes - Security
Forbes - Security
美团技术团队
Stack Overflow Blog
Stack Overflow Blog
SecWiki News
SecWiki News
H
Heimdal Security Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
MyScale Blog
MyScale Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
S
Security @ Cisco Blogs
Google DeepMind News
Google DeepMind News
V
V2EX
大猫的无限游戏
大猫的无限游戏
阮一峰的网络日志
阮一峰的网络日志
S
Security Affairs
L
LangChain Blog
The Hacker News
The Hacker News
F
Full Disclosure
aimingoo的专栏
aimingoo的专栏
Hacker News - Newest:
Hacker News - Newest: "LLM"
腾讯CDC
Webroot Blog
Webroot Blog
A
About on SuperTechFans
H
Hacker News: Front Page
Cyberwarzone
Cyberwarzone
WordPress大学
WordPress大学
L
LINUX DO - 热门话题
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Attack and Defense Labs
Attack and Defense Labs
M
MIT News - Artificial intelligence

博客园 - kuning的程序博客

第一章 第一课 Using WPF Control Cmd,powershell 参考 百度WSUS 我也转关于软件测试的文章 了解WMI 英文面试题 据说是微软面试哦 算法 之 万年历 算法 之 哥德巴赫猜想 - kuning的程序博客 C# 理论学习 之 面向对象设计 C# 理论学习 之 类、组,名称空间 C# 深入学习 之 Winform记录日志 C#深入学习 之 委托和事件 C#数据结构-排序之快速排序法 .Net本地化资源 PHP之安装篇 Sql Server中的行列互换 再叙2005Web控件(一) - kuning的程序博客 - 博客园 Poket PC 与 sqlserver2000(以上) RDA 方案
第一章 第二课 Using Resources
kuning的程序博客 · 2011-06-01 · via 博客园 - kuning的程序博客

After this lesson, you will be able to:
■ Embed a binary resource in an application.
■ Retrieve a binary resource by using code.
■ Retrieve a binary resource by using pack URI syntax.
■ Access a resource in another assembly by using pack URI syntax.
■ Add a content file to an application.
■ Create a resource-only DLL.
■ Load and access a resource-only DLL.
■ Create a logical resource.
■ Create an application resource.
■ Access a resource in XAML.
■ Explain the difference between a static resource and a dynamic resource.
■ Create a resource dictionary.
■ Merge resource dictionaries.
■ Decide where to store a resource.
■ Access a resource object in code.

一、Binary Resources

Binary resources enable you to compile large binary files in your application assemblies and
retrieve them for use in your application. Binary resources are different from logical resources,
which can be defined and accessed in XAML files

1. Embedding Resources

Add the file to your project and set the file’s Build Action property to Resource. When the application is
compiled, the resource is compiled automatically as a resource and embedded in your application

Do not set the Build Action property to Embedded Resource, which embeds the resource
using a different resource management scheme that is less accessible from WPF
applications.

Using embeding Resources

<Image Source="Pics/Image1.jpg"></Image>
<Image Source="Pics\Image1.jpg"></Image>
<Image Source="pack://application:,,,/Pics/Image1.jpg" Margin="17,90,61,22" Name="Image1" Stretch="Fill"/>

Using embeded Resources in other assembly:

pack://application:,,,/<AssemblyName>;component/<Folder>/<FileName>

2. Content Files

Embedding filess would require the application to be recompiled, and the embedding files would require pack uri, so updated frequently files and media MediaPlayer and MediaElement controls do not support the pack URI syntax

How to add content files:

Set the Build Action property for this file to Content.

Set Copy To Output Directory property to Copy Always.

Using content files

<Image Source="pack://siteOfOrigin:,,,/OfficeFrontDoor.jpg"/>

The siteOfOrigin:,,, syntax means different things depending on the location from which
the application was originally installed. If the application is a full-trust desktop application
that was installed using Windows Installer, the siteOfOrigin:,,, syntax in a pack URI refers to
the root directory of the application.
If the application is a full-trust application that was installed using ClickOnce, the
siteOfOrigin:,,,
syntax refers to the Uniform Resource Locator (URL) or the Universal Naming
Convention (UNC) path from which the application was originally deployed.
For a partial-trust application deployed with ClickOnce or an XAML Browser Application
(XBAP), siteOfOrigin:,,, refers to the URL or UNC path that hosts the application.
Pack URIs that use the siteOfOrigin:,,, syntax always point to loose files (that is, files that
are copied to the output directory but are not compiled); they never point to embedded
resources. Thus, the files they reference should always exist in the directory specified by the
siteOfOrigin:,,, syntax in a loose, uncompiled state.