How do I set the path of my ImageSource in Code behind?
Last post 04-24-2008 3:56 AM by Sylvie. 2 replies.
Sort Posts:
04-23-2008 11:22 AM
How do I set the path of my ImageSource in Code behind?

Hello dear,

I do have a string value called value where I stored the path of my Imagesource. Now I want to set it in my c# code behind in SL2.0. I tried this:

Xaml:
<
Image x:Name="productImage" RenderTransformOrigin="0.5,0.5" Width="216.575" Height="284.601" Source="Images/weinfelder.jpg" Stretch="Uniform" Canvas.Left="-7.812" Canvas.Top="-40.588"> 

Code-Behind:
Uri
uriImage = new Uri(value, UriKind.Relative);
this.productImage.Source = uriImage;

But it doesn´t work. How can I do that? Do you also know How to handle with
this.productPrice1["Canvas.Left"] = 30; that is setting the Canvas.Left Position of an Control in the code-behind.

Any Help will be much appreciated. Tanks ;)

Sylvie

Sylvie

Joined on 01-09-2008
Posts 26
04-23-2008 11:41 AM
Marked as Answer
Re: How do I set the path of my ImageSource in Code behind?

For image source :

this.productImage.Source = new BitmapImage(uriImage);

For canvas:

Canvas.SetLeft(this.productPrice1, 30);

Thierry Bouquain
Ucaya
http://www.ucaya.com

thierry.bouquain

Joined on 05-06-2007
Nantes, France
Posts 224
04-24-2008 3:56 AM
Re: How do I set the path of my ImageSource in Code behind?

Thanks a lot Thierry!

Sylvie

Joined on 01-09-2008
Posts 26