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