Quantcast
Channel: wpftoolkit Discussions Rss Feed
Viewing all articles
Browse latest Browse all 2157

New Post: Using Events of the Wizard

$
0
0
Hi,

1) There are 6 events on the Wizard control. 2 of them (Next and Previous) can be cancelled by the user by setting e.Cancel = true. Depending on what is currently displayed on the WizardPage, it could be correct to cancel the movement to the next or previous wizardPage.

The 4 others events (Finish, Help, Cancel and PageChanged) cannot be cancelled since we want direct action with those. For the Cancel event, it would be weird to cancel a cancel event.

2) The "_wizard" comes from the "x:Name" of my Wizard defined in XAML :
<Grid>
      <xctk:Wizard x:Name="_wizard" 
                   FinishButtonClosesWindow="True">
         <xctk:WizardPage Title="Welcome to my Wizard"
                             Description="This Wizard will walk you though how to do something." />
         <xctk:WizardPage PageType="Interior"
                             Title="Page 1"
                             Description="This is the first page in the process." />
         <xctk:WizardPage PageType="Interior"
                             Title="Page 2"
                             Description="This is the second page in the process" />
         <xctk:WizardPage PageType="Interior"
                             Title="Last Page"
                             Description="This is the last page in the process"
                             CanFinish="True" />
      </xctk:Wizard>
</Grid>
 public partial class MainWindow : Window
  {
    public MainWindow()
    {
      InitializeComponent();
      _wizard.Next += _wizard_Next;
    }

    private void _wizard_Next( object sender, Xceed.Wpf.Toolkit.Core.CancelRoutedEventArgs e )
    {

    }
  }
If you really want to make everything in code-behind, here's a way :
 public partial class MainWindow : Window
  {
    public MainWindow()
    {
      InitializeComponent();

      var wizard = new Wizard();
      wizard.FinishButtonClosesWindow = true;
      wizard.Next += this.Wizard_Next;
      wizard.Items.Add( new WizardPage() { Title = "Welcome to my Wizard", Description = "This Wizard will walk you though how to do something." } );
      wizard.Items.Add( new WizardPage() { Title = "Page 1", Description = "This is the first page in the process.", PageType = WizardPageType.Interior } );
      wizard.Items.Add( new WizardPage() { Title = "Page 2", Description = "This is the second page in the process.", PageType = WizardPageType.Interior } );
      wizard.Items.Add( new WizardPage() { Title = "Last Page", Description = "This is the last page in the process.", PageType = WizardPageType.Interior, CanFinish = true } );

      this.Content = wizard;
    }

    private void Wizard_Next( object sender, Xceed.Wpf.Toolkit.Core.CancelRoutedEventArgs e )
    {
    }
  }

Viewing all articles
Browse latest Browse all 2157

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>