0

我摘自windows 8.1示例的StorageDataSource和GetVirtualizedFilesVector示例一段代码在我的项目中可以成功运行,但是我改成这样:从ApplicationData.current.localFolder存入我的图片不显示成功

protected override void OnNavigatedTo(NavigationEventArgs e)
{
        var queryOptions = new QueryOptions();
        queryOptions.FolderDepth = FolderDepth.Deep;
        queryOptions.IndexerOption = IndexerOption.UseIndexerWhenAvailable;
        queryOptions.SortOrder.Clear();
        var sortEntry = new SortEntry();
        sortEntry.PropertyName = "System.FileName";
        sortEntry.AscendingOrder = true;
        queryOptions.SortOrder.Add(sortEntry);

        //var fileQuery = KnownFolders.PicturesLibrary.CreateFileQueryWithOptions(queryOptions);
        var fileQuery = ApplicationData.Current.LocalFolder.CreateFileQueryWithOptions(queryOptions);
        const uint size = 400; // default size for PicturesView mode
        var fileInformationFactory = new FileInformationFactory(fileQuery, ThumbnailMode.PicturesView, size, ThumbnailOptions.UseCurrentScale, true);
        itemsViewSource.Source = fileInformationFactory.GetVirtualizedFilesVector();
}

注释说原始示例代码,注释,下面是我希望能够运行的代码行。多谢!

4

1 回答 1

0

你有图片库的访问权限吗?要像您的代码一样进行编程访问,应用程序应该拥有它。您可以从 Package.appxmanifest 中打开/关闭它。

于 2014-05-18T08:59:34.893 回答