protected virtual WizardNavigationButton CreateFinishButton(IWizard wizard) { var button = new WizardNavigationButton { Content = _languageService.GetString("Wizard_Finish"), IsVisibleEvaluator = () => wizard.IsLastPage(), Command = new TaskCommand(async() => { await wizard.ResumeAsync(); }, () => { if (!wizard.HandleNavigationStates) { return(true); } if (!Wizard.CanResume) { return(false); } // Don't validate var validationSummary = wizard.GetValidationContextForCurrentPage(false); if (!validationSummary.HasErrors) { return(true); } return(false); }) }; return(button); }
protected virtual WizardNavigationButton CreateFinishButton(IWizard wizard) { var button = new WizardNavigationButton { Content = _languageService.GetString("Wizard_Finish"), IsVisibleEvaluator = () => wizard.IsLastPage(), StyleEvaluator = (x) => { var styleName = wizard.IsLastPage() ? "WizardNavigationPrimaryButtonStyle" : "WizardNavigationButtonStyle"; var application = System.Windows.Application.Current; return(application?.TryFindResource(styleName) as Style); }, Command = new TaskCommand(async() => { await wizard.ResumeAsync(); }, () => { if (!wizard.HandleNavigationStates) { return(true); } if (!Wizard.CanResume) { return(false); } // Don't validate var validationSummary = wizard.GetValidationContextForCurrentPage(false); if (!validationSummary.HasErrors) { return(true); } return(false); }) }; return(button); }
public static async Task MoveForwardOrResumeAsync(this IWizard wizard) { Argument.IsNotNull(() => wizard); if (wizard.CanMoveForward) { Log.Debug("Moving forward from MoveNextOrResumeAsync()"); await wizard.MoveForwardAsync(); return; } if (wizard.CanResume) { Log.Debug("Resuming from MoveNextOrResumeAsync()"); await wizard.ResumeAsync(); return; } Log.Debug("Could not move forward or resume from MoveNextOrResumeAsync()"); }
protected override WizardNavigationButton CreateFinishButton(IWizard wizard) { var button = new WizardNavigationButton { Content = _languageService.GetString("Wizard_Finish"), IsVisibleEvaluator = () => true, StyleEvaluator = (x) => { var styleName = wizard.IsLastPage() ? "WizardNavigationPrimaryButtonStyle" : "WizardNavigationButtonStyle"; var application = System.Windows.Application.Current; return(application?.TryFindResource(styleName) as Style); }, Command = new TaskCommand(async() => { if (wizard.IsLastPage()) { // Just resume await wizard.ResumeAsync(); return; } var wizardPages = wizard.Pages.ToList(); var summaryPage = wizardPages.LastOrDefault(x => x is SummaryWizardPage) as SummaryWizardPage; if (summaryPage is not null) { // Navigate to summary page var typedWizard = wizard as WizardBase; if (typedWizard is null) { // Manually move next while (true) { if (wizard.IsLastPage()) { break; } if (ReferenceEquals(wizardPages, typedWizard)) { break; } } return; } await typedWizard.MoveToPageAsync(summaryPage); return; } // Last resort: try to resume normally await wizard.ResumeAsync(); }, () => { if (!wizard.HandleNavigationStates) { return(true); } //var validationSummary = this.GetValidationSummary(true); //return !validationSummary.HasErrors && !validationSummary.HasWarnings && Wizard.CanResume; return(wizard.CanResume); }) }; return(button); }