I have a RibbonWindow as start window and now I want to create an input option for persons, articles etc.
If I use further windows they will all open as new windows.
Since not so many controls are needed, I wanted to use pages that are displayed in the RibbonWindow.
Therefore I have the following entry in the RibbonWindow
- "WorkZone" Grid.Row="2" Grid.RowSpan="2" NavigationUIVisibility="Hidden">
In the CodeBehind the page is displayed with
- private void BtnLief_Click(object sender, RoutedEventArgs e)
- {
- WorkZone.NavigationService.Navigate(new Uri("PageRSTGruppen.xaml", UriKind.Relative));
- }
This works.
When I click on Close the page should be closed.
Problem is, there is no "Close()" option in the page.
How can I remove the page from the RibbonWindow or where can I find an example?
Maybe this is not a good approach with pages and I should work with windows?
Thanks a lot
Greeting
Hans-Peter
Sandhiya PriyaPosted Oct 27, 2025, 9:12 AM
you’re using a WPF RibbonWindow as your main shell and want to show multiple Pages (like Person, Article, etc.) inside a
Frame(WorkZone) without opening new windows.The navigation from a button works fine, but now you want to close the current Page (essentially go back to the RibbonWindow view).
Let’s go through the correct and clean way to do that.
1. Use the Frame’s NavigationService Correctly
Since you already have:
And you navigate using:
To “close” the page (i.e., go back or clear the content), you have a few options depending on what behavior you want.
Option 1: Go back (if navigation history exists)
If you navigated from another page (e.g. a main/home page), you can call this in your Page code-behind:
This will return to the previous page in the navigation history.
Option 2: Clear the Frame’s content (no back navigation)
If you just want to remove the Page and show an empty area (no navigation history):
In your Page (like
PageRSTGruppen.xaml.cs):This effectively “closes” the Page from within itself, leaving the
Frameblank or ready for another navigation.Option 3: Return to a specific home/start Page
If you have a “HomePage.xaml” (the default view), you can navigate back to it explicitly:
This works well if you want to always go back to the start screen.
Optional: Disable Navigation Journal (if you don’t want history)
If you don’t want WPF to remember previous pages (so Back doesn’t work), add this to your
Frame:And in code-behind after navigation:
This keeps navigation one-way (cleaner for simple page switching).
Recommended Pattern for RibbonWindow Apps
If you’re planning to have multiple “modules” (Persons, Articles, etc.), it’s cleanest to:
Keep the RibbonWindow as a shell
Use the
Frameto load pages dynamicallyAdd a helper method in the RibbonWindow for navigation:
Then from anywhere (even inside a Page), you can do:
That gives you full control without worrying about the navigation stack.