我正在cppWinRT空白应用程序的Visual Studio模板项目中工作。
我想做的是从MainPage
类内的OnLaunched
函数调用App
中定义的函数。
到目前为止,我的理论是我需要的是类似的东西:
MainPage* mainPageImpl = from_abi<BlankApp1::implementation::MainPage>(/*somehow get a pointer to the MainPage instance*/);
mainPageImpl->myFunction();
但是我不确定这是否正确。
答案 0 :(得分:0)
使用get_self
将投影类转换为实现类。
MainPage* mainPageImpl = get_self<MainPage>(Window::Current().Content().try_as<Frame>().Content().try_as<BlankApp1::MainPage>());
mainPageImpl->myFunction();