Wpf多页导航 [英] Wpf Navigation with multiple pages

查看:57
本文介绍了Wpf多页导航的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我是这个WPF的新手慢慢学习东西。



我被困在一个东西,我的情况就像我有多个页面,即page1.xaml,page2.xaml ....等,我必须显示这些Window1.xaml(wpf窗口)中的页面。



这个window1.xaml包含一个网格(建议使用其他面板是否更好),它被分成多个块(行和列。



外部块将填充标准模板(例如一些图像或一些控件),并且一个块被分配给显示页面。



可以假设类似于codeproject网站,其中标准代码项目模板将位于顶部,无论我们导航到哪个页面。



如何实现此显示wpf中单个窗口中的多个页面。还请帮我如何使用向前和向后导航导航到页面,如我们在浏览器中的使用方式。



如果我使用navigationwindow我无法使用任何控件,如grid,stackpanle,button。



谢谢

Hello everyone,

I am newbie to this WPF learning out things slowly.

I am stuck with one stuff, my situation is like i have multiple pages i.e page1.xaml,page2.xaml....etc, i have to display these pages in Window1.xaml(wpf window).

This window1.xaml contains a grid (suggest if using other panel is better) which is divided into number of blocks(rows and columns.

The outer blocks of which will be filled with standard template (say some images or with some controls)and one block is assigned to display pages.

Can be assumed similar to codeproject website where the standard codeproject template will be on top irrespective of pages we navigate to.

How can i achieve this displaying of multiple pages in a single window in wpf. Also please help me how to navigate to pages using forward and backward navigation like how we use in browser.

If i use navigationwindow i am not able to use any controls like grid, stackpanle,button.

Thank you

推荐答案

看一下框架类 [ ^ ] - 您可以在页面底部找到有关导航的信息。



这是一个很好的例子:

WPF Navigation [ ^ ]作者:Paul Stovell。



祝你好运

Espen Harlinn
Have a look at the Frame Class[^] - You''ll find information about navigation at the bottom of the page.

Here is a nice example:
WPF Navigation[^] by Paul Stovell.

Best regards
Espen Harlinn


嗨。

导航可以通过Galasofts MVVM Framework Messenger实现一种方式。为WPF下载包和参考相应的dll。



添加一个Frame控件在您的网格中的位置,比如你要加载页面的FramePages。您可以通过在xaml中指定页面网址来设置默认来源。



例如



在你的窗口中1。 xaml构造函数,注册Galasoft的Default messanger为



window1(){

Messenger.Default.Register< uri>(这, Window1Navigator,(uri)=> this.FramePages.Navigate(uri));

}



来自任何地方的电话代码包括在ViewModels Messenger.Default.Send< uri>(UriCreateFromPagePath,Window1Navigator);



或者页面上有说NavigationService.Navigate(UriCreateFromPagePath)。



我希望这会有所帮助。我愿意接受更正。
Hi.
Navigation can one way be achieved using Galasofts MVVM Framework Messenger. Download package and reference appropriate dll for WPF.

Add add a Frame control in your location within the grid, say FramePages where you want to load pages. You can set default source by specifying page url in the xaml.

eg

In your window1.xaml constructor, register Galasoft''s Default messanger as

window1(){
Messenger.Default.Register<uri>(this, "Window1Navigator", (uri) => this.FramePages.Navigate(uri));
}

Call from anywhere in the code including in ViewModels Messenger.Default.Send<uri>(UriCreateFromPagePath, "Window1Navigator");

Or withing the pages say NavigationService.Navigate(UriCreateFromPagePath).

I hope this helps. I am open to correction.


这篇关于Wpf多页导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆