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