如何从自定义类内部的代码导航到页面。例如,假设我的 MainPage.xaml.cs 中有以下代码:
private void DoSomething(object sender, RoutedEventArgs e)
{
var work = new Work();
work.doMore();
}
在这堂课中,我希望导航实际发生在哪里:
public class Work
{
public void DoMore()
{
// this is what I've tried, but doesn't work
var myFrame = new Frame();
myFrame.Navigate(typeof(HomePage));
}
}