问题
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