Winrt和PhotoEditor示例中的收藏范围

时间:2018-08-17 07:52:04

标签: collections uwp c++-winrt

  1. Winrt :: Windows :: Foundation :: Collection仅具有没有具体集合类型的接口。

  2. 我被告知要使用Platorm :: Collections,但不确定如何从Winrt :: Windows :: ?????中获得该信息。我认为它仅适用于C ++ / Cx

3。我已经在PhotoEditor示例中复制并使用了Observable_Vector,但是在构建时出现错误,说我的vector类型没有实现GetTrustLevel()。

  1. 如果我不能在WInrt中使用Platform :: Collections,则意味着当前只有一个示例如何在Winrt(PhotoEditor)中使用集合,这也意味着Winrt中的onyl具体集合是phtotEditor中的Observable_Vector。 li>

需要帮助来阐明c ++-Winrt中的集合范围。 还有关于使用PhotoEditor中相同的Observable_vector时为什么获得信任级别错误的任何帮助。

谢谢

1 个答案:

答案 0 :(得分:0)

通常,您不必实现自己的集合。 C ++ / WinRT提供了一组帮助器函数,用于创建各种常见的通用集合类型。例如:

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>();
}

还支持创建自定义集合。我在这里介绍了其中一些选项:

https://kennykerr.ca/2018/05/12/cppwinrt-creating-collections-simply-efficiently/