Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is Uri Pack, and ":,,," in a BitmapImage?

What I add a Image.Source I have to type the following:

playIcon.Source = new BitmapImage(new Uri(@"pack://application:,,,/TempApplication2;component/Images/play.png")); 

I'm moving from web development to WPF C# and I don't get why setting a Path has extra stuff in it, where in CSS I simply add a Path string.

Can someone explain why there is Uri, pack, and the ":,,,", Application2:component?

I'm new to WPF C#.

like image 830
KMC Avatar asked Mar 22 '11 11:03

KMC


People also ask

What is Uri in WPF?

In Windows Presentation Foundation (WPF), uniform resource identifiers (URIs) are used to identify and load files in many ways, including the following: Specifying the user interface (UI) to show when an application first starts. Loading images.

What is pack application?

Application Pack means the object code software utility release(s) that are designed to work with the Software that may be, in Blackboard's sole discretion, issued in between Updates, designated by AP#, and/or later incorporated into Updates or Upgrades.

How do you change the source of an image in UWP?

Here's how to set the source to an image from the app package. Image img = new Image(); BitmapImage bitmapImage = new BitmapImage(); Uri uri = new Uri("ms-appx:///Assets/Logo.png"); bitmapImage. UriSource = uri; img. Source = bitmapImage; // OR Image img = new Image(); img.

How do I add a resource to a project in WPF?

To add a Resource Dictionary into your WPF application, right click the WPF project > add a Resource Dictionary. Now apply the resource "myAnotherBackgroundColor" to button background and observe the changes.


1 Answers

The pack uri is used to identify & locate resources, files in application and remote. The pack uri in WPF uses 'pack://authority/path' format. And this is the line from MSDN which explains this format, 'The authority specifies the type of package that a part is contained by, while the path specifies the location of a part within a package'

WPF supports two authorities: application:/// and siteoforigin:///. The application:/// authority identifies resource files, content files. The siteoforigin:/// authority identifies site of origin files.

":///" is written ":,,," because the "/" character must be replaced with the "," character, and reserved characters such as "%" and "?" must be escaped and URI that points to a package and must conform to RFC 2396.

For more info please read "Pack URIs in WPF"

I'm also learning WPF. This is what i have understood about Pack Uri in WPF till now.

like image 129
Code0987 Avatar answered Oct 02 '22 02:10

Code0987