There are articles like Accessing an Embedded Resource Using a Uri
(with pack://application)
How to load embebbed resource image in WPF?
D.D.K-2637
966
Reputation points
Hi,
from this post I was able to load the image with the absolute imagepath, but is this works on the client machine?
I found this answer quite similar to the way I do it on winform but I am having difficulty getting this Properties from code (WindowsFormsApplication1.Properties.Resources).
How to declare or access this Properties?
Thanks !
Developer technologies | Windows Presentation Foundation
Developer technologies | Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
Developer technologies | C#
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
Answer accepted by question author
-
Castorix31 91,501 Reputation points2021-04-07T05:17:33.233+00:00
1 additional answer
Sort by: Most helpful
-
HowardPaggerton 86 Reputation points
2021-10-11T09:46:52.3+00:00 To embed an image as a resource, add it to your project and set its Build Action to Resource. You can access this image at run-time using a Uri. The URI for a simple resource just includes the path to the image.
private void Button_Click(object sender, RoutedEventArgs e) { try { BitmapImage bmi = new BitmapImage(new Uri("pack://application:,,,/Images/Ted.jpg")); MessageBox.Show(string.Format("Image is {0}x{1} pixels", bmi.Width, bmi.Height)); } catch (Exception xx) { MessageBox.Show(xx.ToString()); } }See details here