C# WPF 应用程序(不是浏览器)和导航
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15156625/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
WPF application (not browser) and navigation
提问by Frank
I want to develop a desktop application based on WPF. How do I navigate via C# code from one page to another or from one page in a window?
我想开发一个基于 WPF 的桌面应用程序。如何通过 C# 代码从一个页面导航到另一个页面或从窗口中的一个页面导航?
采纳答案by greg
Take a look at the following links below - these will give you a better understanding of navigating through a WPF application providing examples and sample apps.
请查看下面的以下链接 - 这些链接将让您更好地了解通过提供示例和示例应用程序的 WPF 应用程序进行导航。
How to Build, Manage and Navigate the User Interface of a WPF Application
A really easy way to navigate through an application I find is that if you add a Frame
within a Window
and then for your other corresponding pages, use Page
and you need to do in the code behind of your window is as follows;
我发现浏览应用程序的一个非常简单的方法是,如果您Frame
在 a 中添加 aWindow
然后为您的其他相应页面,使用Page
并且您需要在窗口后面的代码中执行如下操作;
FrameContent.Navigate(new ExampleView());
Hope these links help!
希望这些链接有帮助!
回答by Pylyp Lebediev
There is simple example of navigation by using Data Templates and ContentControl
有使用数据模板和 ContentControl导航的简单示例