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?

4 Answers 4

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

Sign up to request clarification or add additional context in comments.

Comments

1

M working on Windows phone 8 and i used this.

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

Comments

0
Image img = new Image();
img.Source = new Uri("<your path here>");

I hope this helps.

Comments

0

please check this

just use a class "ImageSourceConverter"

img1.Source = (ImageSource)new ImageSourceConverter().ConvertFromString("/Assets/check.png");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.