collections - Winrt 和 PhotoEditor 示例中的集合范围
问题描述
Winrt::Windows::Foundation::Collection 只有接口,没有具体的集合类型。
我被告知要使用 Platorm::Collections,但不确定您是如何从 Winrt::Windows::????? 获得的。我以为它只适用于 C++/Cx
3.我在 PhotoEditor 示例中复制并使用了 Observable_Vector,但在构建时出现错误,说我的向量类型没有实现 GetTrustLevel()。
- 如果我不能在 WInrt 中使用 Platform::Collections,这意味着目前只有一个示例说明如何将集合与 Winrt (PhotoEditor) 一起使用,这也意味着 Winrt 中的唯一具体集合是 phtotEditor 中的 Observable_Vector。
需要帮助澄清 c++-Winrt 中的集合范围。以及在使用来自 PhotoEditor 的相同 Observable_vector 时为什么会出现信任级别错误的任何帮助。
谢谢
解决方案
通常,您不必实现自己的集合。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/
推荐阅读
- java - java服务器套接字编程向客户端返回空值
- java - java awt中从字符串参数到颜色
- r - R中的增量指示符列
- windows - 需要读取 location.txt 与 Tableau 并使用 '&' 作为字符串处理行,而不是在 .bat 文件中转义
- c# - ASP.net,寻找一个参数以确保有 1 个大写字母和一个数字
- arrays - Spring data mongodb聚合过滤器列表
- java - 由于空行,我最近在 netbeans 中运行代码时出错
- python - 使用蒙版合并到图像的单一方法
- python - 如何从 Python 脚本/代码调用 Spark2-submit 命令
- reactjs - “上下文”类型缺少“上下文”类型的以下属性
':提供者、消费者 TS2345