<Window x:Class="FrameSample.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<TextBlock>Outside area of frame</TextBlock>
<Frame Source="Page1.xaml">
</Frame>
</Grid>
</Window>
navigate to a URI in a WPF Frame
<Window x:Class="FrameSample.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<TextBlock>Outside area of frame</TextBlock>
<Frame Name="FrameWithinGrid" >
</Frame>
<Button Height="23" Margin="114,12,25,0"
Name="button1" VerticalAlignment="Top" Click="button1_Click">Navigate to C# Corner
</Button>
</Grid>
</Window>
private void button1_Click(object sender, RoutedEventArgs e)
{
FrameWithinGrid.Navigate(new System.Uri("Page1.xaml",
UriKind.RelativeOrAbsolute));
}
navigate to an external website URL and opens the ASPX page within a Frame
FrameWithinGrid.Source = new Uri("http://www.c-sharpcorner.com/Default.aspx", UriKind.Absolute);
this code first creates a NavigationWindow and then sets its Source to a URI
NavigationWindow window = new NavigationWindow();
Uri source = new Uri("http://www.c-sharpcorner.com/Default.aspx", UriKind.Absolute);
window.Source = source; window.Show();
private void NavigationViewItemHome_OnClick(object sender, RoutedEventArgs e)
{
FrameMain.Navigate(new PageItems());
}
References
https://www.c-sharpcorner.com/UploadFile/mahesh/using-xaml-frame-in-wpf857/
https://www.youtube.com/watch?v=YoZcAx_0rNM