Reputation: 10552
Hey all i am trying to find a way to load an image via the WebClient using a WFP window.... The code below loads just fine when i am using a normal Windows Form:
Dim wc As New Net.WebClient
picNextTopic1.Image = Image.FromStream(wc.OpenRead(theAPI.ImgURL(2).Replace("{width}", "50").Replace("{height}", "50")))
However, this doesnt seem to work for WPF???
The WPF seems to use a .source for images? How can i convert that code above in order to use it with a WPF window?
Upvotes: 0
Views: 319
Reputation: 1907
WPF is not Windows Forms. You need to build WPF applications completely different. Properties, INotifyPropertyChanged etc.
But to your problem:
Dim wc As New WebClient()
Dim bytes = wc.DownloadData("http://....")
Dim ms = New MemoryStream(bytes)
Dim img = New BitmapImage()
ms.Seek(0, SeekOrigin.Begin)
img.BeginInit()
img.StreamSource = ms
img.EndInit()
picNextTopic1.Source = img
Upvotes: 1