diff --git a/examples/Demo/Shared/Microsoft.FluentUI.AspNetCore.Components.xml b/examples/Demo/Shared/Microsoft.FluentUI.AspNetCore.Components.xml index 9cbb57147e..3ca6c314d6 100644 --- a/examples/Demo/Shared/Microsoft.FluentUI.AspNetCore.Components.xml +++ b/examples/Demo/Shared/Microsoft.FluentUI.AspNetCore.Components.xml @@ -9469,6 +9469,7 @@ This configuration overrides the whole rendering of the bottom-right section of the Wizard, including the built-in buttons and thus provides a full control over it. Custom Wizard buttons do not trigger the component OnChange and OnFinish events. + The OnChange event can be triggered using the method from your code. @@ -9503,6 +9504,14 @@ + + + Navigate to the specified step, with or without validate the current EditContexts. + + Index number of the step to display + Validate the EditContext. Default is false. + + diff --git a/examples/Demo/Shared/Pages/Wizard/Examples/WizardCustomized.razor b/examples/Demo/Shared/Pages/Wizard/Examples/WizardCustomized.razor index 49736a69a1..0e5b1790a9 100644 --- a/examples/Demo/Shared/Pages/Wizard/Examples/WizardCustomized.razor +++ b/examples/Demo/Shared/Pages/Wizard/Examples/WizardCustomized.razor @@ -11,12 +11,13 @@ } - - +
Intro @@ -29,7 +30,7 @@ ut blandit dui ullamcorper faucibus. Interdum et malesuada fames ac ante ipsum. - +
Get Started @@ -40,7 +41,7 @@ Fusce vel porta ex, imperdiet molestie nisl. Vestibulum eu ultricies mauris, eget aliquam quam. - +
Set budget @@ -52,7 +53,7 @@ turpis, eget molestie ipsum. - +
Summary @@ -74,16 +75,16 @@
@if (index > 0) { - Go to first page - Previous + Go to first page + Previous }
@if (index != lastStepIndex) { - Next - Go to last page + Next + Go to last page }
} @@ -92,5 +93,11 @@ @code { + FluentWizard MyWizard = default!; int Value = 0; + + void OnStepChange(FluentWizardStepChangeEventArgs e) + { + DemoLogger.WriteLine($"Go to step {e.TargetLabel} (#{e.TargetIndex})"); + } } diff --git a/src/Core/Components/Wizard/FluentWizard.razor.cs b/src/Core/Components/Wizard/FluentWizard.razor.cs index 460f2edcd7..dc66be79c5 100644 --- a/src/Core/Components/Wizard/FluentWizard.razor.cs +++ b/src/Core/Components/Wizard/FluentWizard.razor.cs @@ -118,6 +118,7 @@ public int Value /// This configuration overrides the whole rendering of the bottom-right section of the Wizard, /// including the built-in buttons and thus provides a full control over it. /// Custom Wizard buttons do not trigger the component OnChange and OnFinish events. + /// The OnChange event can be triggered using the method from your code. ///
[Parameter] public RenderFragment? ButtonTemplate { get; set; } @@ -248,7 +249,19 @@ protected virtual async Task OnFinishHandlerAsync(MouseEventArgs e) } } - internal async Task GoToStepAsync(int targetIndex, bool validateEditContexts) + /// + /// Navigate to the specified step, with or without validate the current EditContexts. + /// + /// Index number of the step to display + /// Validate the EditContext. Default is false. + /// + public Task GoToStepAsync(int step, bool validateEditContexts = false) + { + Value = step; + return ValidateAndGoToStepAsync(step, validateEditContexts); + } + + internal async Task ValidateAndGoToStepAsync(int targetIndex, bool validateEditContexts) { var stepChangeArgs = await OnStepChangeHandlerAsync(targetIndex, validateEditContexts); var isCanceled = stepChangeArgs?.IsCancelled ?? false; diff --git a/src/Core/Components/Wizard/FluentWizardStep.razor.cs b/src/Core/Components/Wizard/FluentWizardStep.razor.cs index 94339bfbb7..2b0bb4af67 100644 --- a/src/Core/Components/Wizard/FluentWizardStep.razor.cs +++ b/src/Core/Components/Wizard/FluentWizardStep.razor.cs @@ -192,7 +192,7 @@ private async Task OnClickHandlerAsync() return; } - await FluentWizard.GoToStepAsync(Index, validateEditContexts: Index > FluentWizard.Value); + await FluentWizard.ValidateAndGoToStepAsync(Index, validateEditContexts: Index > FluentWizard.Value); } private bool IsStepClickable