URIs in Windows Presentation Foundation
It seems that understanding and using uniform resource identifiers (URI) is essential in WPF. After searching web and MSDN help I found following articles useful:
With a bit of simplification, I can describe the URI as a new method for identifying the relative or absolute location of a file.
The key element of the URI is the package scheme. which represent the logical path of a content. It contains two parts Authority and Path.
WPF supports two authorities:
MSDN: “The application:/// authority identifies application data files that are known at compile time, including resource and content files. The siteoforigin:/// authority identifies site of origin files.”
I found that Application authority is adequate in majority of cases including accessing a file or a resource from the local or referenced assembly.
Important: to conform to RFC 2396, the “/” character must be replaced with the “,” character and other reserved characters must be escaped including “%” and “?”
Following examples shows pack URI for different scenarios:
Resource file – local assembly
Resource file in subfolder – local assembly
Resource file – referenced assembly
Resource file in subfolder of referenced assembly
Resource file in versioned referenced assembly
Content file in subfolder
Site of origin file
Site of origin file in subfolder