My Windows Store (aka Windows 8) application uses the default Grid Application template to show the items. The item template there includes an image with overlaid text information. To diminish the size of application I do not store the images for every item, instead I save an Uri with absolute path (http) to the webserver where the image resides. I modified the standard template to bind to the image Uri (I had to convert the Uri to string for this to work properly) and now whenever I start the application all the images are downloaded and shown automatically by the Image control.
What I now want is to automatically save the images which were once downloaded and modify the Uris of the downloaded images to those pointing to the local storage. Here I bump into two problems:
- I can't get the ImageOpened event to fire if I bind the complete ItemTemplate from the
StandardStyles.xaml
This is the binding from my GroupedItemsPage.xaml
:
<GridView
x:Name="itemGridView"
ItemTemplate="{StaticResource Standard250x250ItemTemplate}">
The bound template was modified to fire an event (StandardStyles.xaml
):
<DataTemplate x:Key="Standard250x250ItemTemplate">
<Image Source="{Binding ImageUri}" ImageOpened="Image_ImageOpened"/>
</DataTemplate>
The Image_ImageOpened
event handler is defined in the code-behind file (`GroupedItemsPage.xaml.cs'), but never fires:
private void Image_ImageOpened(object sender, RoutedEventArgs e)
{
}
- I don't know how to store the content of the Image framework element as a binary file.