WPF Navigate Pages from outside frame

对着背影说爱祢 提交于 2019-12-11 16:46:20

问题


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).


回答1:


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

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


来源:https://stackoverflow.com/questions/28139522/wpf-navigate-pages-from-outside-frame

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!