Questions tagged [pack-uri]

17 questions
38
votes
1 answer

How can I get a BitmapImage from a Resource?

My assembly includes an image with BuildAction==Resource. I want to obtain a BitmapImage from this embedded resource. I can load a BitmapImage from file like this: var bitmap = new BitmapImage(new Uri(path)); But how to I create a Uri that will…
mackenir
  • 10,801
  • 16
  • 68
  • 100
34
votes
3 answers

Avoiding Visual Studio designer errors when WPF resource is defined in separate project

How can I avoid Visual Studio designer errors when a WPF resource is defined in separate project? I have three projects in a composite WPF application: the main application, an "infrastructure" library, and a "module" library. The main application…
sourcenouveau
  • 29,356
  • 35
  • 146
  • 243
15
votes
4 answers

In WPF, how do I reference a font in a resource library in code behind?

I have an application that uses a separate library assembly for resources (but not a resource-only assembly with no code), and I would like to include a custom font in the library. I am able to get the font, which is an Open Type Font, to load if I…
axanpi
  • 731
  • 9
  • 16
14
votes
1 answer

Detect whether WPF resource exists, based on URI

Given a pack:// URI, what's the best way to tell whether a compiled resource (e.g. a PNG image, compiled with a Build Action of "Resource") actually exists at that URI? After some stumbling around, I came up with this code, which works but is…
Joe White
  • 94,807
  • 60
  • 220
  • 330
12
votes
4 answers

At design time pack uri is valid, but not at runtime?

I'm setting a Button's content to an Image. It looks something like this: In my project I have a subfolder named NavigationImages and within that…
Ashley Grenon
  • 9,305
  • 4
  • 41
  • 54
4
votes
3 answers

Pack URI and path not resolving image in WPF

I have the following directory structure Project \Images +view.png control.xaml and in the control I have a button defined by the following XAML:
1
vote
2 answers

Prism v4, MEF, WPF - Using proper Uri for module graphic

My solution's structure is: CI.Frontier.Classic contains a MEF module. My application uses the RibbonWindow control, and the modules define what menu items should be created. I can successfully add a button to the ribbon control from the…
Chris Klepeis
  • 9,783
  • 16
  • 83
  • 149
1
vote
1 answer

Pack URI not working for generic.xaml merged dictionaries

I made a custom control library and made a control named "FlipView" in the root path. Then I removed the style in Generic.xaml and moved it to its own Resource dictionary named FlipView.xaml in the root path. Now I merge that resource dictionary…
wingerse
  • 3,670
  • 1
  • 29
  • 61
1
vote
1 answer

How can I access a resource image within XAML in a user control library?

I'm writing a library of WPF user controls and am having trouble with a resource image that I'm trying to access via some XAML. Just for fun, the image displays as expected at design time and only fails at run time. I've tried setting the build…
Tom Wright
  • 11,278
  • 15
  • 74
  • 148
1
vote
1 answer

Merging a resource from another Assembly in Silverlight

I added a Resource Dictionary named ResourceDictionary1 to my silverlight project. I also added a Silverlight Class Library to my project named OtherAssembly, then in this new assembly I added a new Resource Dictionary named…
Rafael
  • 2,413
  • 4
  • 32
  • 54
1
vote
1 answer

Navigating up a directory using the pack://siteoforigin

Hi, I am trying to navigate up the folder tree to a file using siteoforigin. I can get to the subfolders but how do I navigate up one? Here is the code that I have tried StreamResourceInfo info = Application.GetRemoteStream(new…
TheColin
  • 11
  • 3
0
votes
0 answers

packing image resource into nuget library and accessing it

I have a nuget package which contains some logos which should be accessible. The logos are located in the Resources Folder: [![enter image description here][1]][1] The logos are set up as embedded resource. I can access them with the following pack…
julian bechtold
  • 1,875
  • 2
  • 19
  • 49
0
votes
0 answers

File not found exceptions regardless of how the file is referenced

I have a String to Img converter for displaying images in a DataGrid based on results of various methods that run, but for a reason I can't get my head around why my code can't find the images. This is my converter, testing various different paths…
0
votes
1 answer

c# have sound files in build

I need to make a game for school. I was adding some sound effects and music. I have the paths to the .wav in the class and it will play them, but only when I start the game from the bin map in the project. I figgered out that the files are not…
Bart Kalkman
  • 103
  • 1
  • 10
0
votes
0 answers

Exception when referencing a resource dictionary

My Solution consists of the following projects: ServiceTools.Com ServiceTools.UI (Startup) ServiceTools.UI.Controls ServiceTools.UI.Themes In UI.Controls I've created a custom Button Control which derives from Button. This Custom button should…
Th1sD0t
  • 1,089
  • 3
  • 11
  • 37
1
2