【发布时间】:2016-10-02 07:09:15
【问题描述】:
我正在为我的 UWP 应用程序使用 Cortana,它运行良好。 但是当我尝试调用不在 app.xaml.cs 中的方法时,我失败了。
我想做什么:
// Switch the content of my Frame (works so far)
Frame rootFrame = Window.Current.Content as Frame;
MainPage page = rootFrame.Content as MainPage;
// cframe references my XAML Frame in the MainPage
page.cframe.Navigate(typeof(MyClass));
// Now the content of the frame is changed and I want to call a method from
// MyClass.xaml.cs
MyClass p = rootFrame.Content as MyClass;
// Here I get a System.NullReferenceException when I try to call
// the "callWebservice()" method from MyClass.xaml.cs
p.callWebservice();
如何访问?
感谢您的帮助。
【问题讨论】:
标签: uwp windows-10-universal cortana