Home > DeveloperSection > Forums > Bitmap images Binding
Tanuj Kumar

Total Post:134

Points:940
Posted on    December-18-2013 12:46 AM

 WPF WPF 
Ratings:


 1 Reply(s)
 1229  View(s)
Rate this:

What is the problem in this code ? Why the firstimage did not show on XAML page when I am binding the source of image in XAML to firstimage here in the code? The class contains the code is not a partial class.

if (ImagesAsSource[realty.ObjectId].Count == 0)

//private static Uri _baseUri = new Uri("ms-appx:///");

{

    Uri img = new Uri(_baseUri, "Assets/back.jpg");

    BitmapImage result = new BitmapImage();

    result.UriSource = img;

    // firstimage  is type of ImageSoure

    firstimage  =result;

}

//I tried this:

//private static Uri _baseUri = new Uri("ms-appx:///");

{

    Uri img = new Uri(_baseUri, "Assets/back.jpg");

    BitmapImage result = new BitmapImage(img );

    // firstimage  is type of ImageSoure

    firstimage  =result;

}



ezra heywood
ezra heywood

Total Post:145

Points:1019
Posted on    December-18-2013 1:23 AM

Hi Tanuj,

You should try something like this:

Uri img = new Uri(_baseUri, "Assets/back.jpg");

var webClient = new WebClient();

byte[] imageBytes = webClient.DownloadData(img);

BitmapImage result = new BitmapImage(imageBytes);

In fact I don't know constructor for your BitmapImage, so may be you should convert byte[] into Stream


Don't want to miss updates? Please click the below button!

Follow MindStick