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 refer to an embedded resource image?
When I try and create a 'pack URI' (for example pac...
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 references the other projects via their output DLLs (the projects are not located in a sin...
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:
<Button Click="Search"
Grid.Column="1"
Margin="0,5,5, 0"
HorizontalAlignment="Right">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
...
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 clumsy:
private static bool CanLoadResource(Uri uri)
{
try
{
Application.GetRe...