Timur Mustafaev
Timur Mustafaev

Reputation: 4929

Get picture data from Image control WPF

I'm new to WPF. I was programming for Windows Forms Applications, and there was Picture Box with Image property. But in WPF there is Image instead of Picture Box. How to get it's value? I mean the image data.

Upvotes: 0

Views: 3298

Answers (1)

Haris Hasan
Haris Hasan

Reputation: 30097

you can do that by using Image.Source property.

You will find a lot of samples on internet about it. For example code below sets image source, you can get the image similarly

Image myImage3 = new Image();
BitmapImage bi3 = new BitmapImage();
bi3.BeginInit();
bi3.UriSource = new Uri("smiley_stackpanel.PNG", UriKind.Relative);
bi3.EndInit();
myImage3.Stretch = Stretch.Fill;
myImage3.Source = bi3;

  //get the source
  BitmapImage imgSource = myImage3.Source;

Upvotes: 1

Related Questions