问题
Winrt::Windows::Foundation::Collection only has interfaces no concrete collection type.
I have been told to use Platorm::Collections, but not sure how you get to that from Winrt::Windows::?????. I thought its only for C++/Cx
3.I have copied and used the Observable_Vector in PhotoEditor sample but am getting error on build saying my type in vector does not implement GetTrustLevel().
- If i cannot use Platform::Collections in WInrt, that means currently there is only one example of how to use collections with Winrt (PhotoEditor) and that will also mean onyl concrete collection in Winrt is the Observable_Vector in phtotEditor.
Need help to clarify the scope of collection in c++-Winrt. And also any help as to why am Getting Trust level error when using same Observable_vector from PhotoEditor.
Thanks
回答1:
In general, you should not have to implement your own collections. C++/WinRT provides a set of helper functions for creating a variety of common generic collection types. For example:
using namespace winrt;
using namespace Windows::Foundation::Collections;
int main()
{
IVector<int> a = single_threaded_vector<int>({ 1,2,3 });
IObservableMap<hstring, int> b = single_threaded_observable_map<hstring, int>();
}
There is also support for creating custom collections. I described some of those options here:
https://kennykerr.ca/2018/05/12/cppwinrt-creating-collections-simply-efficiently/
来源:https://stackoverflow.com/questions/51890703/scope-of-collections-in-winrt-and-photoeditor-example