How to: Create a Frame That Navigates

This example shows how to create a Frame control that navigates to external Web sites and also to pages within an application.

Example

The following Extensible Application Markup Language (XAML) example shows how to create a Frame control.

<Frame Name = "myFrame" Grid.Column="0" Grid.Row="1" 
       Background="LightBlue"/>

The following code example shows how to navigate to external Web sites and also to a page in an application.

    Private Sub BrowseAHomePage(ByVal sender As Object, ByVal e As RoutedEventArgs)
      If CType(VisualBasic.IsChecked, Boolean) Then
        myFrame.Navigate(New System.Uri("https://msdn.microsoft.com/vbasic/"))
      ElseIf CType(VisualCSharp.IsChecked, Boolean) Then
        myFrame.Navigate(New System.Uri("https://msdn.microsoft.com/vcsharp/"))
      ElseIf CType(AnotherPage.IsChecked, Boolean) Then
        myFrame.Navigate(New System.Uri("AnotherPage.xaml", UriKind.RelativeOrAbsolute))
      End If

    End Sub
private void BrowseAHomePage(object sender, RoutedEventArgs e)
{
  if ((Boolean)VisualBasic.IsChecked)
    myFrame.Navigate(new System.Uri("https://msdn.microsoft.com/vbasic/")); 
  else if ((Boolean)VisualCSharp.IsChecked)
    myFrame.Navigate(new System.Uri("https://msdn.microsoft.com/vcsharp/")); 
  else if ((Boolean)AnotherPage.IsChecked)
    myFrame.Navigate(new System.Uri("AnotherPage.xaml",
                     UriKind.RelativeOrAbsolute));

 }

See Also

Reference

Frame