tags:

views:

9

answers:

2

Hi guys,

This is nothing short of embarrassing to ask but I'm having no luck with searches today.

I have an image plane.png which I have added as an existing item to my project "Rem". I have map.xaml in this, but since I want to add multiple "plane.png" images to this, I am trying to create them in map.xaml.cs

The XAML code to do what I want is simply: <Image Source="plane.png"/>

Would some kind soul be able to tell me what the C# equivalent to this is?

Thanks very much in advance,

M

A: 
Image i = new Image();    
BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.UriSource = new Uri("plane.png", UriKind.Relative);
bi.EndInit();
i.Source = bi;
Aaron
Simple and genius, you just made my day. Thanks very much, exactly what I was looking for; I had been playing around with something like that all afternoon but the UriKind.Relative was what I'd missed. Have a good one.
Myn