2

In XAML, I learned to specify image source with below code:

<Image Source="/WaivePadBankAnim;component/Images/Consumer/search_button_full.png" />

How would I do it in C# .cs?

JohanSJA
  • 705
  • 2
  • 9
  • 21

4 Answers4

2

Try this

Image image = new Image();
image.UriSource = new Uri("/WaivePadBankAnim;component/Images/Consumer/search_button_full.png")

Try this

Adding WPF Controls Progrrammatically

Community
  • 1
  • 1
gagabu
  • 154
  • 1
  • 6
1

M working on Windows phone 8 and i used this.

OrderImage1.Source = new BitmapImage(new Uri("///Assets/images/order_bread.png"));

Muhammad
  • 169
  • 8
0

please check this

just use a class "ImageSourceConverter"

img1.Source = (ImageSource)new ImageSourceConverter().ConvertFromString("/Assets/check.png");
0
Image img = new Image();
img.Source = new Uri("<your path here>");

I hope this helps.

hyp
  • 1,370
  • 1
  • 9
  • 21