Freigeben über


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 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));
              
 }

For the complete sample, see Frame Sample.

See Also

Reference

Frame