Example #1
0
        /// <summary>
        /// Steps to the specified page.
        /// </summary>
        /// <param name="nextPage">
        /// The page to go.
        /// If the value is <c>null</c>, the wizard steps to the next page or finishes the wizard if the current page is the last one.
        /// </param>
        /// <seealso cref="NextPage()"/>
        public virtual void NextPage(WizardPage nextPage)
        {
            if (nextPage == null)
            {
                if (CurrentPage == Pages.Last() || CurrentPage.IsFinishPage)
                {
                    Finish();
                    return;
                }
            }
            else if (!Pages.Contains(nextPage))
            {
                throw new ArgumentException(
                          "When specifying a value for nextPage, it must already be in the Pages collection.", "nextPage");
            }

            if (CurrentPage == null || CurrentPage.CommitPage())
            {
                if (!DesignerProperties.GetIsInDesignMode(this))
                {
                    pageHistory.Push(CurrentPage);
                }
                CurrentPage = nextPage ?? strategy.GetNextPage(this);
            }
        }