我想通过 WPF 制作一个包含几页的程序。
我现在有一个Window和几个Page。
为了导航,我使用
this.Content = new Page1();
在主窗口中(从Window到Page),以及
((Window)this.Parent).Content = new Page1();
页面之间(从Page到Page),因为Page只能是Windowor的子元素Frame。
但是,上面的第二行代码看起来很丑。
有没有更好的方法来实现相同的目标?
我之前从几个 Windows Phone 应用程序中编写过代码,我认为在 s 之间导航可能Page比隐藏/显示元素(例如Grids)更好。