Ckiszka

I have an application that gets the html path of a picture from a website. The image path is a webservice (ashx). The problem is it works in XAML but not in code behind. In trouble shooting I hard coded the Image Source path in XAML and the image appears. If I hard code the image in code behind it does not work... Here is my code behind.

Dim BitmapImage As New Imaging.BitmapImage
BitmapImage.BeginInit()
BitmapImage.UriSource = New Uri("http://www.somewebsite.com/getimage.ashx x=x")
BitmapImage.EndInit()

Image.Source = BitmapImage

Thanks.




Re: Windows Presentation Foundation (WPF) Changing Image Source property in VB.Net code behind. Image from webservice.

Yi-Lun Luo - MSFT

Hello, what does this web service method return The parameter for the Uri constructor should be the actual path of the image, not a service method. If the service method returns the actual path, you can pass its return value as the parameter:

BitmapImage.UriSource = New Uri(myService.GetImage())






Re: Windows Presentation Foundation (WPF) Changing Image Source property in VB.Net code behind. Image from webservice.

Ckiszka

When I try to reference the service in VS it appears not to have any public methods. In a regular aspx web page I can place a label down, format a <img> tag with "src" of the returned string from the web service as the text property and it renders the picture on my button click event.

To be more specific here is the src="http://www.bungie.net/Stats/halo2emblem.ashx s=90&amp;0=0&amp;1=3&amp;2=3&amp;3=0&amp;fi=30&amp;bi=4&amp;fl=1" Im trying to get my gamer picture. If I set this as the image source property for my image in XAML at design time it renders. If I try to change it with code behind using a click event --- New Uri (path) it renders a blank image.

I really want to start developing in WPF but am not educated enough to work profeciently. I can do this task in a regular aspx page pretty quick with a label. I need to study more and sharpen up in WPF Smile Until then please assist...lol Smile

Thanks.






Re: Windows Presentation Foundation (WPF) Changing Image Source property in VB.Net code behind. Image from webservice.

JDPeckham

wpf learning curve really steep. check out wpf unleashed by adam nathan, i've really enjoyed it.