0

i want to download images from specified Uri s and show it in Grid View

<GridView>
    <GridView.ItemTemplate>
        <DataTemplate>
             <Image Width="150" Height="150" Source="{Binding Source={}}"/>
        </DataTemplate>
    </GridView.ItemTemplate>
</GridView>
AaBbCc
  • 39
  • 10
  • use `Uri` to download image and set it into `ImageSource` property of your `Image` tag from code behind – Saurabh Srivastava Apr 28 '16 at 04:16
  • Have you looked at this http://stackoverflow.com/questions/33854553/create-imagebrush-bitmap-and-writeablebitmap-from-an-url ? – JTIM Apr 29 '16 at 07:00

1 Answers1

0

If you have a model class, set the following property & bind it to the image element.

Public class YourClass
{

public string imageuri { get ; set ; } //web image uri

public BitmapImage ImageUrl
        {
            get
            {
                if (!string.IsNullOrEmpty(imageuri))
                {
                    BitmapImage bmi = new BitmapImage();
                    bmi.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
                    bmi.UriSource = new Uri(imageuri, UriKind.Absolute);
                    return bmi;
                }
                return null;
            }
        }
}

<GridView>
    <GridView.ItemTemplate>
        <DataTemplate>
             <Image Width="150" Height="150" Source="{Binding ImageUrl,Mode=Twoway}"/>
        </DataTemplate>
    </GridView.ItemTemplate>
</GridView>
asitis
  • 3,023
  • 1
  • 31
  • 55