microsoft / microsoft/microsoft-ui-xaml
Unhandled Win32 exception when CollectionViewSource.Source is set via GetVirtualizedFilesVector() WinUI 1.6
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 8.4k
- Forks
- 942
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 105
Description
Describe the bug
I am porting a UWP app that heavily uses the FileInformationFactory.GetVirtualizedFilesVector() set to a CollectionViewSource and bound to GridView and other UserControls. The app has been working really well for 4 years now, and I decided to port it to WinUI 1.6 given that UWP seems to be being progressively abandonned.
Therefore, I really hope someone could help me on how I can get this code to work on WinUI or advise me to wait otherwise. This app is farily complex so I would like to avoid working on the upgrade if I know that the FileInformationFactory or the CollectionViewSource is not supported (for instance)
I narrowed down the crash to the following. Create a blank WinUI 1.6 App, Setup the code to pick a folder (code not shown but taken from the docs on WinUI. The FolderPicker returns a StorageFolder, named Folder, successfully, and then run the following simple code on the main thread:
var queryOptions = new QueryOptions() { FolderDepth = FolderDepth.Deep };
var query = Folder.CreateFileQueryWithOptions(queryOptions);
var fileInfoVectors =
new FileInformationFactory(query, ThumbnailMode.SingleItem, 192,
ThumbnailOptions.UseCurrentScale, delayLoad: false).GetVirtualizedFilesVector();
var collectionViewSource = new CollectionViewSource()
{
Source = fileInfoVectors
};
In debug mode, Visual Sutio will throw an unhandled Win32 Exception. The reason is Source = fileInfoVectors with the option FolderDepth.Deep.
Question 1
Is this expected for WinUI 1.6 and any plan to have CollectionViewSource and/Or the FileInformatinFactory fully supported?
Question 2
What is the workaround, knowing that I will not use await Folder.GetFilesAsync() or FileInformation.GetFilesAsync(); as they are extremally slow and consume memory.
Thank you for any guidance.
Steps to reproduce the bug
Exectue the code above in a blank app after having picked a folder named here Folder
Expected behavior
Should not throw.
Screenshots
No response
NuGet package version
WinUI 3 - Windows App SDK 1.6.5: 1.6.250205002
Windows version
Windows 11 (24H2): Build 26100
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue in a blank WinUI 3 app using the supplied FileInformationFactory, QueryOptions, and CollectionViewSource code after selecting a folder. Start with the FolderDepth.Deep configuration and confirm that assigning fileInfoVectors to CollectionViewSource.Source raises the unhandled Win32 exception. Done would require a confirmed compatibility result or documented workaround, but the issue does not identify an implementation entry point.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100