locked
[UWP]What is the return type of Windows.Storage.BulkAccess.GetVirtualizedItemsVector()? RRS feed

  • Question

  • The documentation for GetVirtualizedItemsVector defines the return value as 'object'. I am looking for the actual interface returned. In short:

    var FileInformationFactory fif = new FileInformationFactory(itemQuery, Windows.Storage.FileProperties.ThumbnailMode.ListView, 
                    40, Windows.Storage.FileProperties.ThumbnailOptions.ResizeThumbnail);
    ??? dataSource = fif.GetVirtualizedItemsVector() as ???;

    I tried, as a guess, Windows.Foundation.Collections.IObservableVector<Windows.Storage.BulkAccess.IStorageItemInformation>, but that doesn't work.

    For context, I need to create a ViewModel for my UX that composes the result of some extended file attributes (per my earlier question here). I've jumped over the aforementioned hurdle using a Brokered Component, but now I need to work with the extended attributes plus the icons associated with the files. I can hand-roll the whole virtualized model thing (using SHGetStockIconInfo I guess), but that smacks of re-inventing the wheel. There is documentation on binding the object with magic, but I want to work with the object (interface) itself.

    Concrete question is: what might I substitute ??? with in the snippit above.

    • Edited by therealkenc Sunday, August 20, 2017 11:15 PM
    • Edited by Breeze Liu Monday, August 28, 2017 9:52 AM add[UWP]
    Sunday, August 20, 2017 11:14 PM

Answers

  • Hi therealkenc,

    It is also the object type and it is usually used as the Source of CollectionViewSource Class. We typically define a CollectionViewSource as a XAML resource and bind to it using the {StaticResource} markup extension. You can then set its Source property in code-behind to a supported collection type. Here is a example code,

                var fileInformationFactory = new FileInformationFactory(itemQuery, ThumbnailMode.PicturesView, size, ThumbnailOptions.UseCurrentScale, true);
                CollectionViewSource itemsViewSource = new CollectionViewSource();//for testing and easy to understand
                itemsViewSource.Source = fileInformationFactory.GetVirtualizedItemsVector();

    Best regards,

    Breeze


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by therealkenc Monday, August 21, 2017 8:43 PM
    Monday, August 21, 2017 7:39 AM

All replies

  • Hi therealkenc,

    It is also the object type and it is usually used as the Source of CollectionViewSource Class. We typically define a CollectionViewSource as a XAML resource and bind to it using the {StaticResource} markup extension. You can then set its Source property in code-behind to a supported collection type. Here is a example code,

                var fileInformationFactory = new FileInformationFactory(itemQuery, ThumbnailMode.PicturesView, size, ThumbnailOptions.UseCurrentScale, true);
                CollectionViewSource itemsViewSource = new CollectionViewSource();//for testing and easy to understand
                itemsViewSource.Source = fileInformationFactory.GetVirtualizedItemsVector();

    Best regards,

    Breeze


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by therealkenc Monday, August 21, 2017 8:43 PM
    Monday, August 21, 2017 7:39 AM
  • Thank-you. Very helpful!
    Monday, August 21, 2017 8:44 PM
  • I would still like to know how to operate on the returned 'object' though, which is what I really need here. I can do an await on FileInformationFactory.GetItemsAsync(), but I think I am just defeating the asynchronous purpose of the class. Anecdotally it is slow. Basically I need to proxy the items returned. I can assign it to a source per the article "Data binding in depth", and per your response, no problem. But my ViewModel has the usual File/Folder properties (name, icon, modification timestamp, size) plus other stuff, ie the custom extended attributes of the file. What would be the best approach to compose the usual file/folder properties with other values? By way of illustration, let's say my files had a property "weight", in kilograms.
    Monday, August 21, 2017 9:04 PM