Navigation over a Dynamically-Generated Topology Sample

This sample illustrates how to support navigation over a dynamically-generated navigation topology. Building the Sample Install the Windows Software Development Kit (SDK) and open its build environment command window.

7,534 times
Add to favorites
E-mail Twitter Digg Facebook
namespace AdaptiveTopologySample
    using System;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Navigation;

    /// <summary>
    /// Interaction logic for WizardPage1.xaml
    /// </summary>

    public partial class WizardPage1 : PageFunction<WizardResult>
        public WizardPage1(object WizardData)

            // Bind Wizard state to UI
            this.DataContext = WizardData;

            this.Loaded += new RoutedEventHandler(WizardPage1_Loaded);

        void WizardPage1_Loaded(object sender, RoutedEventArgs e)
            // Enable buttons based on position
            this.backButton.IsEnabled = WizardNavigationHub.Current.CanGoBack(this);
            this.nextButton.IsEnabled = WizardNavigationHub.Current.CanGoNext(this);
            this.nextButton.IsDefault = WizardNavigationHub.Current.CanGoNext(this);
            this.finishButton.IsEnabled = WizardNavigationHub.Current.CanFinish(this);
            this.finishButton.IsDefault = WizardNavigationHub.Current.CanFinish(this);
        void backButton_Click(object sender, RoutedEventArgs e)
            // Go to previous Wizard page

        void nextButton_Click(object sender, RoutedEventArgs e)
            // Go to next Wizard page
            if (this.NavigationService.CanGoForward) this.NavigationService.GoForward();
                PageFunction<WizardResult> nextPage = WizardNavigationHub.Current.GetNextWizardPage(this);
                nextPage.Return += new ReturnEventHandler<WizardResult>(WizardPage_Return);

        void cancelButton_Click(object sender, RoutedEventArgs e)
            // Cancel the Wizard and don't return any data
            OnReturn(new ReturnEventArgs<WizardResult>(WizardResult.Canceled));

        void finishButton_Click(object sender, RoutedEventArgs e)
            // Finish the Wizard and return bound data to calling page
            OnReturn(new ReturnEventArgs<WizardResult>(WizardResult.Finished));

        public void WizardPage_Return(object sender, ReturnEventArgs<WizardResult> e)
            // This is called when the next page returns, so return what they are returning