Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7805619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:16:57+00:00 2026-06-02T02:16:57+00:00

MY application has 3 pages (one MainWindow and 2 pages where simple selections are

  • 0

MY application has 3 pages (one MainWindow and 2 pages where simple selections are made).

Currently i use the following navigation structure to switch between the pages http://azerdark.wordpress.com/2010/04/23/multi-page-application-in-wpf/.
It basically uses a interface to pass the reference of a page and creates new instances.

The idea is i can only have 1 window open at one time. For example when i navigate from Page A to B, B replaces the content of A. The order is Always A -> B -> C -> A (back to main Window) or A -> B -> A.

All the content gets displayed in 1 window at all times in other words.
With my current solution i have the problem that i instantiate a new instance of the page every time it switches (for example A -> B -> A has 2x New PageA() as result.

This on its turn results in having to use a lot of static methods and classes which i do not really like.

Is there a better solution for this that does not require a entire overhaul of my current application navigation structure?

In my current solution i use a static ObversableCollection list to remember a number of controls that get dynamically created so when i go back to page A (mainWindow) everything remains the same.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T02:16:58+00:00Added an answer on June 2, 2026 at 2:16 am

    I don’t really understand why would you use navigation in such a simple settings (3 pages and fixed navigation structure). Much easier way would be:

    1. Use MainWindow as content placeholder
    2. Create UserControls as pages
    3. Define static class to hold pages in distinct properties. Initialize them if need be (singleton instances).
    4. Use MainWindow.SetPage(Pages.First) to change pages.

    In code, this would pretty much look like this:

    public class MainWindow : Window
    {
        // ...
        public void SetPage(UserControl page)
        {
             this.Content = page;
        }
    }
    
    // ...
    
    public static class Pages
    {
        private FirstUserControl _first;
        private SecondUserControl _second;
        private ThirdUserControl _third;
        private MainWindow _window = Application.Current.MainWindow;
    
        public UserControl First
        {
            get 
            { 
                if (_first == null) 
                    _first =  new FirstUserControl();
                return _first;
            }
        }
        // ...
    }
    
    // Somewhere in B (after A -> B)
    
        MainWindow.SetPage(Pages.First);
    

    Though if you really need the navigation, you could use just the static part of it and pass the singletoned instances to your SwitchPage method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

One of the pages in my application has a set of links that when
I have a winforms application that has one tabcontrol with 2 pages. On both
I have a simple Android application that has a TabBar and one of the
A 3rd party web application has a cross-scripting security issue. There is one page
We have a Flex application which has several 'pages' worth of content. Each time
We have an application which has about 15000 pages. For better SEO reasons we
I have a ASP.NET web application which has more than 100 pages. Each page
I have a Web application ( http://www.holidaystreets.com ), it has around 120,000+ pages. Whenever
Our application has many controls that are created dynamically. For example, a navigation pane
We are using Primefaces 3M4 and one of our pages has a p:dataTable which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.