locked
How do i set the uri for binding an image to an image control? RRS feed

  • Question

  • Hi guys,

    How do i set the uri for binding an image to an image control? i'm getting the image name from the gridview's click event. it returns the foldername/imagename.. for example Big/1.jpg .Here the Folder big is in the root folder of the project. I want to use this as the binding source for the image control. But i'm getting an uri format exception. Can anybody help me please. 

            

    private void ImageGalleryGridBasket_ItemClick_1(object sender, ItemClickEventArgs e)
            {
                string Path = e.ClickedItem.ToString();
               
                image1.Source= new BitmapImage(new Uri(@"pack://application:,,,/"+Path,UriKind.RelativeOrAbsolute));
               
                
            }

    Thanks and Regards, Prashanth MP.


    • Edited by JohnnyWalker9 Friday, March 30, 2012 5:56 AM Correction
    Friday, March 30, 2012 5:51 AM

Answers

All replies

  • Just use "ms-appx://" instead of "pack ...".

    Friday, March 30, 2012 7:20 AM
  •   string Path = e.ClickedItem.ToString();
                BitmapImage bi = new BitmapImage();
                bi.UriSource = new Uri(this.BaseUri, Path);
                image1.Source = bi;

    I got it...

    Thanks and Regards, Prashanth MP.

    Friday, March 30, 2012 11:19 AM