# Loading page in WPF

Guys, I have a basic WPF application. Contains App.xaml as always and a Mainwindow.xaml. I've created also some pages like page1/2/3. I want to load for example page1.xaml in mainwindow.xaml. Is this possible? And also want to close it so the content of mainwindow.xaml will stay in there.

I dont want this to be a navigation application with the left/right arrows at the top.

-

## 3 Answers

You can add a frame to your main page and load the pages on it.

-

I came here to add that there are many ways to load the pages into the frame:

By setting the source (as @Shift mentioned)

frame1.Source = new Uri("Page1.xaml", UriKind.RelativeOrAbsolute);


By setting the Content:

frame1.Content= new Page1();


By using the NavigationService:

frame1.NavigationService.Navigate(new Page1());

-

Adding a frame and setting the source for the frame like makes my day :)

frame1.Source = new Uri("Page1.xaml", UriKind.RelativeOrAbsolute);

-