Reputation: 1338
I have multiple StorageFile
s available as Task<StorageFile>
s in my ViewModel, I want to bind an Image in my View to it.
A BitmapImage shouldn't be made in the ViewModel, because it's in the XAML namespace and requires the UI thread (which I fail to do).
How should I tackle this problem? Using a ValueConverter can't be done, as opening the StorageFile is async...
PS: I can't use an URI, the StorageFile is located in the LocalCache folder...
Upvotes: 1
Views: 819
Reputation: 4306
Try just use Path
property from StorageFile
class:
<ListView ItemsSource="{Binding ImageItems}"
Grid.Row="1">
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Text="{Binding Path}"/>
<Image Grid.Row="1">
<Image.Source>
<BitmapImage UriSource="{Binding Path}"/>
</Image.Source>
</Image>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
Where ImageItems
it's public List<StorageFile> ImageItems
property
Upvotes: 4