WPF从外部框架导航页面 [英] WPF Navigate Pages from outside frame

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

问题描述

我必须创建wpf浏览器应用程序。它有2帧:

I have to create wpf browser application.It have 2 frames:

<DockPanel>
        <Frame Name ="MenuFrame" Source="Menu1.xaml" Height="Auto" Width="150" NavigationUIVisibility="Hidden" BorderBrush="#35000000" BorderThickness="1">
        </Frame>
        <ScrollViewer Grid.Row="2" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
            <Frame Name ="ContentFrame" Source="Content.xaml"  HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" NavigationUIVisibility="Hidden" BorderBrush="#35000000" BorderThickness="2" VerticalAlignment="Stretch">
            </Frame>
        </ScrollViewer>
</DockPanel>

通过推送内容框架中的按钮,我成功通过内容框架中的页面导航到页面。

I succeeded to navigate from Page to page in Content Frame through pushing on button in Content Frame.

NavigationService nav = NavigationService.GetNavigationService(this);
nav.Navigate(new Uri("/Controls/Page1.xaml", UriKind.RelativeOrAbsolute));)

如何从外部框架菜单框架执行相同的操作。我想在第一帧,菜单框架中有一个超链接,并在第二帧(内容框架)中导航页面。

How can I do the same behavior but from outside frame, Menu Frame. I want to have a hyperlink in first frame, Menu Frame, and to navigate pages in second frame (Content Frame).

推荐答案

您可以简单地调用框架本身的导航,如下所示:

You can simply call the navigate on the frame itself, like so:

ContentFrame.Navigate(new Uri("/Controls/Page1.xaml", UriKind.RelativeOrAbsolute));)

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

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