Using IIterable
-
26-05-2021 - |
سؤال
The WinRT API function DataPackage::SetStorageItems
takes a parameter of type IIterable<IStorageItem^>^
. What I have is a single StorageItem^
, not a collection.
I'm a bit confused as to how to create an IIterable collection from this, since I can't find a WinRT collection class that implements the interface. I realize that I can create my own class using IIterable as a base, but my guess is that there are existing classes that I'm just not seeing.
What am I missing here?
I guess this is obvious, but: C++, VS11, Win8, Metro.
المحلول
I think you want the Vector
class from the C++/CX-specific namespace Platform::Collections
:
DataPackage^ package = …;
IStorageItem^ item = …;
Vector<IStorageItem^>^ items = ref new Vector<IStorageItem^>();
items->Append(item);
package->SetStorageItems(items);
لا تنتمي إلى StackOverflow