BITMAP IMAGES BINDING

Tanuj Kumar

Total Post:134

Points:940
Posted by  Tanuj Kumar
WPF 
WPF
 1518  View(s)
Ratings:
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;

}

  1. ezra heywood

    Post:145

    Points:1019
    Re: Bitmap images Binding

    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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!