img = new Image()
{
Height = 150,
Stretch = System.Windows.Media.Stretch.Fill,
Width = 200
};
img.Source = (ImageSource) new ImageSourceConverter()
.ConvertFromString("/FirstDemo;component/Images/Hero.jpg");
After hours of research, trying to assign an image to an image class. I came across this way of assigning an image. I have absolutely no idea why I this code does not run. It does not get any compiler error though.. Odd. its 11 25 pm here btw
Do it this way:
img = new Image();
img.Height = 150;
img.Width = 200;
img.Stretch = Stretch.Fill;
img.Source = new BitmapImage(new Uri("/FirstDemo;component/Images/Hero.jpg"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With