1. Binary resources WPF supports three binary resources, which can be easily used in XAML.
Resource: Embedding resources in assemblies is a bit like Embedded Resource. The difference is that WPF packages related resources to. Resources file, which is then embedded in the assembly file by the compiler. The WPF default URI access method does not support Embedded Resource.
Content: Resources are not embedded in the assembly, just adding a record to the assembly manifest is the same way as we used to know. Resource files must be deployed with other assembly files to the destination directory.
Loose File: This type of resource is usually dynamically determined or joined during runtime.
WPF accesses related resource files through a Uniform Resource Identifier (URI).
(1) Access to resource/content resources
<Image Source="/a.png" />
<Image Source="/xxx/x.png" />
(2) Access to loose resource files (Loose file)
<Image Source="pack://siteOfOrigin:,,,/a.png" />
<Image Source="c:\test\a.png" />
XAML compilation requires that all resource validation be validated, so a valid URI path must be used when using loose resource files. "pack://" represents the Package URI, "Pack://siteoforigin:,,," means starting at the deployment location, and the corresponding "Pack://application:,,," The full path to the Resource resource above should be "pack ://application:,,,/a.png ", but usually we use ellipsis.
<Image Source="pack://application:,,,/a.png" />
Other URI notation also includes the following:
<Image Source="http://www.qidian.com/images/logo.gif" />
<Image Source="\\server1\share\logo.gif" />
<Image Source="file://c:/test/logo.gif" />
(3) Access to resource files in other assemblies
Providing an alternative dedicated resource DLL is also a common programming technique, especially for multiple languages or skin-changing mechanisms. WPF's syntax for accessing other assembly resource files is somewhat odd.
pack://application:,,,/AssemblyReference;Component/ResourceName
Resources for other assemblies must be embedded in a Resource manner.
You cannot omit the backslash before "/assemblyreference".
Component is a keyword and must be included in the URI.
<Image Source="pack://application:,,,/Learn.Library;component/s.gif" />
<Image Source="/Learn.Library;component/s.gif" />