NavigationWindow for a Wizard?

I would like to use a NavigationWindow to present a sequence of pages to the user as a wizard (not the main window).  Can this be done   I want to load several pages into the window when initialized.  I have tried using a CustomContentState to preload entries in the BackStack and then GoBack to return to the first page.  But, that does not seem to work.  The AddBackEntry does not appear to do anything.  My application is just a normal WPF application not a NavigationApplication because the main window is just a window.  What I would really like is to be able to have the window just enable the forward/backward buttons and hold a list of pages.  Of course, there may be branching in time, etc.  Is it possible to use NavigationWindow with the application taking over the back/forward actions   Is there someway to avoid the exceptions that are thrown when there are no entries in the stacks


Answer this question

NavigationWindow for a Wizard?

  • vjnfjvbnhjbvgfb

    Your description fits with what I decided was the case.  Though preloading the back stack does not seem to be an option.  Even after calling AddBackEntry it does not support GoBack.  I ended up just building my own UI for a wizard with the normal buttons.  I think the web browser sense of history and the idea for a wizard are basically differnt, and I did not want to present some weird hybrid UI to the user.

    Thanks for the time you took in posting a reply.

  • RayCh

    Hello Michael,

    Thanks for sharing your experience. What you are asking for is technically possible, but it's not how NavigationWindow is intended to be used. NavigationWindow is modeled after the Web browser: It maintains a history of visited pages. The Forward button will be enabled only after you go back to a previous page... Users don't expect the browser's Forward button to take them to the next step in a wizard (if not already visited and gone back from it).

    The purpose of PageFunctions is to make it easier to chain a number of pages in a wizard-like fashion, supporting going back & forward between pages and "committing the transaction" by returning (calling OnReturn) from the PageFunction(s). Additionally, the RemoveFromJournal property lets you choose whether the visited wizard pages will ultimately remain in the back stack of the internal journal and be shown in the Back button's drop-down menu. And, yes, this model requires the application to provide its own means for getting to the next page, typically as a button or hyperlink within the current page.

    If you want to save replicating the 'Go to next step' UI across all pages as well as the (little) application code associated with that, consider loading your pages in a child Frame. Then the frame will be navigated to the 'pure-content' pages, and the (only) page loaded in the NavigationWindow will include some GUI around the hosted frame that navigates the frame to the next page. Navigations within the child frame will appear in the drop-down menus of the NavigationWindow, and the back/forward buttons will work as expected.

    If you still want to make use of the built-in navigation/journaling framework but also want to provide some alternate navigation UI, you could either completely re-style NavigationWindow or simply hide its predefined navigation chrome (ShowsNavigationUI=false). Your own navigation visuals would then be linked to NavigationWindow's Navigate, GoBack & GoForward methods. (Re-implementing the drop-down menus is somewhat involved but definitely possible.)

    Further, if you really want to couple custom navigation UI with your idea of "front-loading" all the wizard pages in the built-in journal and rewinding to the first page before letting the user take over, you could achieve this by using AddBackEntry(), but this would already be fairly nonstandard use of the navigation framework. Just for the sake of the discussion, here's how this might work:
      - Your CustomContentState-derived class would have to include some identifier of each wizard page (possibly Type or relative URI);
      - After calling AddBackEntry() for each predefined page, call GoBack() the same number of times. (In general, to avoid an exception from GoBack/GoForward(), first test CanGoBack/CaGoForward.)
      - Your implementation of CustomContentState.Reply() should put an instance of the page with the encapsulated id in the element tree of NavigationWindow, for example as the child of some predefined Border element. (This is important: you don't call Navigate(), as that would delete the forward stack. The custom journaling API are generally intended to let you capture and restore state within a single given page.)
      - The root element of each page should be a panel type, not <Page>. 
      - You should also implement IProvideCustomContentState on the root content element loaded in the NavigationWindow or set e.ContentStateToSave in a Navigating event handler.

    Feel free to ask for clarifications or further details, and please post an update with the results of any custom navigation scheme you decide to implement.



  • mina_mina

    That was a good start, but it does not get me what I want.  All the examples have the forward button for the sequence of pages in the page itself.  This seems like such a bad UI to me.  There is this large navigation area at the top that already has a forward button.  Having another next or forward button is only going to confuse users.  What I really want to do is hook up to the forward button provided by NavigationWindow and use that for forward, rather than only having it useful in returning to a prior page visit.  In the case of a structured navigation this should be possible.

  • Dan Kahler

  • NavigationWindow for a Wizard?