SliderView(AppStudio.Uwp.Controls)があります。画像はページをロードするとすぐに表示されますが、リストをスクロールすると消えます。私はこれもListViewでテストしました。同じことがそこでも起こっています。 ItemTemplateには使用スクロール中にSliderViewとListViewで画像が消える
<controls:SliderView x:Name="sliderView" ItemsSource="{x:Bind listForOtherPicturesThumbnails}" ItemTemplate="{StaticResource Hero}"
RelativePanel.Below="mainImage"
RelativePanel.AlignLeftWithPanel="True"
RelativePanel.AlignRightWithPanel="True"
ArrowsVisibility="Visible"
/>
OnNavigatedに次のようにサムネイルが生成さfollows-
<DataTemplate x:Key="Hero" x:DataType="local:StorageItemThumbnailClass">
<Grid Margin="6" Padding="12" Background="White" BorderThickness="1" BorderBrush="LightGray">
<Image Source="{x:Bind Thumbnail, Converter={StaticResource ThumbnailtoImageConverter}}" Stretch="UniformToFill" HorizontalAlignment="Center" VerticalAlignment="Center" />
</Grid>
</DataTemplate>
が
public object Convert(object value, Type targetType, object parameter, string language)
{
BitmapImage image = null;
if (value != null)
{
if (value.GetType() != typeof(StorageItemThumbnail))
{
throw new ArgumentException("Expected a thumbnail");
}
StorageItemThumbnail thumbnail = (StorageItemThumbnail)value;
image = new BitmapImage();
image.SetSource(thumbnail);
}
return (image);
}
converter-画像に
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
otherPicturesPathList = ((PictureWithList)e.Parameter).pathList;
await PopulateListOfOtherPicturesThumbnailsAsync();
Bindings.Update();
}
private async Task PopulateListOfOtherPicturesThumbnailsAsync()
{
if (otherPicturesPathList != null)
{
List<Task<StorageItemThumbnail>> thumbnailOperations = new List<Task<StorageItemThumbnail>>();
foreach (var path in otherPicturesPathList)
{
var storageFile = await StorageFile.GetFileFromPathAsync(path);
thumbnailOperations.Add(storageFile.GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode.PicturesView, 100).AsTask());
}
await Task.WhenAll(thumbnailOperations);
for (int k = 0; k < thumbnailOperations.Count; k++)
{
var task = thumbnailOperations[k];
listForOtherPicturesThumbnails.Add(new StorageItemThumbnailClass { Thumbnail = task.Result });
}
}
}
サムネイル機能 - の通りでありますStorageIt emThumbnailClass-
ページが最初に読み込まれたときに画像がそのまま残るようにこの問題を解決するにはどうすればよいですか?
何もありません。あなたのコードは意味をなさない。 'await storageFile.GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode.PicturesView、100)'の 'StorageItemThumbnail'は' Task '(タイプのサムネイルリスト)に変換できません。 –
しかし、各サムネイル操作を並列に実行するのではなく、順番に実行したいと考えているので、私は 'listForOtherPicturesThumbnails.Add(新しいStorageItemThumbnailClass {Thumbnail = await storageFile.GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode.PicturesView、100) }); '。それでも動作しませんでした。 –