我正在为cppWinRT空白应用程序在Visual Studio模板项目中工作。
我想要做的是从App类内部的OnLaunched函数调用MainPage中定义的函数。
到目前为止,我的理论是,我需要的是类似的东西:
MainPage* mainPageImpl = from_abi<BlankApp1::implementation::MainPage>(/*somehow get a pointer to the MainPage instance*/);
mainPageImpl->myFunction();然而,我不确定这是否是正确的方法。
发布于 2018-12-24 11:31:22
使用get_self将投影类转换为实现类。
MainPage* mainPageImpl = get_self<MainPage>(Window::Current().Content().try_as<Frame>().Content().try_as<BlankApp1::MainPage>());
mainPageImpl->myFunction();https://stackoverflow.com/questions/51529105
复制相似问题