Scope of Collections in Winrt And PhotoEditor example

牧云@^-^@ 提交于 2019-12-11 09:02:53

问题


  1. Winrt::Windows::Foundation::Collection only has interfaces no concrete collection type.

  2. 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().

  1. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!