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
2,854 questions
Developer technologies | C#
11,578 questions
Accepted answer
-
Castorix31 90,686 Reputation points
2021-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