locked
Image source

    Question

  • hi

    i can not set image.source=???

    windows store with C# and Xaml

    i try this :

    imagebox.Source = new Windows.UI.Xaml.Media.ImageSource(new Uri("file://C:/Users/MacBook Pro/Desktop/DL Movie/nama.jpg"));

    but not show image in my image box

    where this code is wrong?! :(



    • Edited by AMIR ameri Monday, November 24, 2014 9:13 PM
    Monday, November 24, 2014 9:09 PM

Answers

  • First, include the image in your Visual Studio project. For example, add it to an Assets folder. Then, use the following URI:

    new Uri("ms-appx:///Assets/nama.jpg")

    Leszek

    My Apps

    Monday, November 24, 2014 9:42 PM
  • Hi,

    You are actually using absolute path from desktop. That won't 

    Try  this- 

    imagebox.Source = new Windows.UI.Xaml.Media.ImageSource(new Uri("ms-appx:/Assets/mypic.png", UriKind.Absolute));


    -Malleswar

    Tuesday, November 25, 2014 12:38 AM
  • thank you very much Leszek.

    its worke

    final code :

     imagebox.Source = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri("ms-appx:///Assets/nama.jpg"));


    Amir Ameri

    • Marked as answer by AMIR ameri Monday, December 01, 2014 8:56 PM
    Tuesday, November 25, 2014 7:36 AM
  • thank you

    its worked without :UriKind.Absolute


    just :

    new Uri("ms-appx:///Assets/nama.jpg")



    Amir Ameri

    • Marked as answer by AMIR ameri Monday, December 01, 2014 8:57 PM
    Tuesday, November 25, 2014 7:39 AM

All replies

  • First, include the image in your Visual Studio project. For example, add it to an Assets folder. Then, use the following URI:

    new Uri("ms-appx:///Assets/nama.jpg")

    Leszek

    My Apps

    Monday, November 24, 2014 9:42 PM
  • Hi,

    You are actually using absolute path from desktop. That won't 

    Try  this- 

    imagebox.Source = new Windows.UI.Xaml.Media.ImageSource(new Uri("ms-appx:/Assets/mypic.png", UriKind.Absolute));


    -Malleswar

    Tuesday, November 25, 2014 12:38 AM
  • thank you very much Leszek.

    its worke

    final code :

     imagebox.Source = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri("ms-appx:///Assets/nama.jpg"));


    Amir Ameri

    • Marked as answer by AMIR ameri Monday, December 01, 2014 8:56 PM
    Tuesday, November 25, 2014 7:36 AM
  • thank you

    its worked without :UriKind.Absolute


    just :

    new Uri("ms-appx:///Assets/nama.jpg")



    Amir Ameri

    • Marked as answer by AMIR ameri Monday, December 01, 2014 8:57 PM
    Tuesday, November 25, 2014 7:39 AM