Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

New Post: Conditional Wizard Pages

$
0
0
Hi,

How about using the binding in the Tag property of the RadioButtons and using the the Checked event to set the WizardPage.NextPage to the RadioButton's Tag :
<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.">
               <StackPanel>
                  <RadioButton x:Name="RadioButton1"
                               Content="Go To FirstPage"
                               Checked="RadioButton_Checked"
                               Tag="{Binding ElementName=Page1}"/>
                  <RadioButton x:Name="RadioButton2"
                               Content="Go To SecondPage"
                               Checked="RadioButton_Checked"
                               Tag="{Binding ElementName=Page2}"/>
               </StackPanel>
            </xctk:WizardPage>
            <xctk:WizardPage x:Name="Page1"
                             PageType="Interior"
                             Title="Page 1"
                             Description="This is the first page in the process."/>
            <xctk:WizardPage x:Name="Page2"
                             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>

 private void RadioButton_Checked( object sender, RoutedEventArgs e )
    {
      RadioButton button = ( sender as RadioButton );
      WizardPage wizardPage = this.FindVisualParent<WizardPage>( button ) as WizardPage;
      wizardPage.NextPage = button.Tag as WizardPage;
    }

    public T FindVisualParent<T>( DependencyObject child ) where T : DependencyObject
    {
      // get parent item
      DependencyObject parentObject = VisualTreeHelper.GetParent( child );

      // we’ve reached the end of the tree
      if( parentObject == null )
        return null;

      // check if the parent matches the type we’re looking for
      T parent = parentObject as T;
      if( parent != null )
      {
        return parent;
      }
      else
      {
        // use recursion to proceed with next level
        return FindVisualParent<T>( parentObject );
      }
 }

Viewing all articles
Browse latest Browse all 4964

Trending Articles



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