Possible to disable or hide the 'Back' button on a step?

Any SharpSetup related discussions are welcome here including but not limited to questions about functionality, suggestions for improvements and technical questions.
BGort
Posts: 5
Joined: Thu May 05, 2016 3:44 pm

Possible to disable or hide the 'Back' button on a step?

Postby BGort » Tue Jun 07, 2016 9:02 pm

Is it possible to disable or hide the 'Back' button on a ModernActionStep?

tomasz_grobelny
Posts: 463
Joined: Sat May 22, 2010 1:26 pm

Re: Possible to disable or hide the 'Back' button on a step?

Postby tomasz_grobelny » Tue Jun 07, 2016 10:15 pm

To achieve this you can add the following code to the constructor of your dialog:

Code: Select all

Entered += (o, s) => { Wizard.BackButton.Enabled = false; };

Obviously instead of Enabled property you may use Visible property.

BGort
Posts: 5
Joined: Thu May 05, 2016 3:44 pm

Re: Possible to disable or hide the 'Back' button on a step?

Postby BGort » Wed Jun 08, 2016 1:49 pm

I do not see a 'BackButton' property on the Wizard object which is why I am having trouble in the first place.

tomasz_grobelny
Posts: 463
Joined: Sat May 22, 2010 1:26 pm

Re: Possible to disable or hide the 'Back' button on a step?

Postby tomasz_grobelny » Wed Jun 08, 2016 8:21 pm

Which UI version are you using? WinForms or WPF? In case it is WPF then there is no easy and direct way to disable Back button. You could:
1. You set the previous step StepType as Transitionary or TransitionaryOnetime - this is the case for eg. InstallationStep.
2. I could add a CanGoBack property to ModernWizard for you (similar to CanGoNext).
3. You could replace style for ModernWizard and write your custom logic for Back button.

Why should the user not be able to go back?

BGort
Posts: 5
Joined: Thu May 05, 2016 3:44 pm

Re: Possible to disable or hide the 'Back' button on a step?

Postby BGort » Wed Jun 08, 2016 9:50 pm

Yes, WPF.

In certain paths through my install, a step may be skipped. In the case of the step I am on, the previous step is always skipped. So, when I go back, the step is skipped and the user forwarded back to the current step.

tomasz_grobelny
Posts: 463
Joined: Sat May 22, 2010 1:26 pm

Re: Possible to disable or hide the 'Back' button on a step?

Postby tomasz_grobelny » Thu Jun 09, 2016 9:59 pm

If the previous step that is to be skipped uses the following code:

Code: Select all

        private void YourSkippedStep_Entering(object sender, ChangeStepRoutedEventArgs e)
        {
            if (Globals.GetVariable<bool?>("YourVariable") == false)
                Wizard.ContinueMove();
        }

then the Back button should go to the step before the skipped one. So the flow would look like this:
1. Click the Back button and go to previous step.
2. Execute the Entering event handler which may call ContinueMove()
3. ContinueMove() notices that you are going backwards and goes to previous step.
4. Go to point 2.

This way you should be able to get the Back button working as expected.

BGort
Posts: 5
Joined: Thu May 05, 2016 3:44 pm

Re: Possible to disable or hide the 'Back' button on a step?

Postby BGort » Mon Jun 13, 2016 8:16 pm

This worked. Thanks much for the help!


Return to “General”

Who is online

Users browsing this forum: No registered users and 7 guests