通过windows phone 8.1运行时组件访问CoreWindow
Accessing CoreWindow from a windows phone 8.1 runtime component
我试图从windows phone 8.1 c++运行时组件访问CoreWindow。组件需要对CoreWindow触发的一些事件做出反应。我有以下代码。
IAsyncAction^ MyClass::RegisterCoreWindowVisibilityChanged()
{
return CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::High,
ref new DispatchedHandler(
[this]
{
auto eventHandler = ref new TypedEventHandler<CoreWindow^, VisibilityChangedEventArgs^>(this, &MyClass::OnCoreWindowVisibilityChanged);
Window::Current->CoreWindow->VisibilityChanged += eventHandler;
}
));
}
当使用该组件的应用程序是通用应用程序时,它可以正常工作,但在silverlight应用程序中由于访问冲突异常而失败。
0xC0000005: Access violation reading location 0x00000000.
显然Windows::Current
在silverlight应用程序中返回null。是否有一种方法可以做到这一点,以便它在silverlight以及windows商店应用程序中工作?
该对象仅在通用应用程序中可用(如文档所示)。
你需要将编译条件化,或者考虑切换到桌面和手机的通用应用程序。
相关文章:
- 通过方法访问结构
- 使用不带参数的函数访问结构元素
- 在C++中访问蓝图类组件的正确方法是什么?
- 如何访问基类向量中的子类变量?(对于实体组件系统)
- 从 WinRT C++组件访问 COM 对象
- 如何访问头文件中类的组件并打印它们的地址?
- 让 Redhawk 组件访问另一个组件的属性
- OpenCL 矢量类型:在启用 C++11 的情况下无法访问联合组件 x,y,z
- 访问QT上的本地用户文件进行Web组件
- 从C++访问现有的 QML 组件
- 通过浏览器使用 Java/C 访问 HTML TextField 组件
- 切换到具有不同数量的标量组件的图像会导致访问违规
- 有关C++/组件数据布局、数据成员访问、方法的一般问题
- 访问冲突0xFEEEFEEE无法访问组件
- 如何访问加载的映像的各个 R/G/B 组件(较新的 C++ API)
- 通过 [ " " ] 或 [int] 为自定义类C++访问组件
- 如何从实体组件系统的子类中访问属性
- 如何设计一个应该同时从C++和C#访问的组件
- c++实体组件系统和使用模板访问组件
- 通过windows phone 8.1运行时组件访问CoreWindow