> For the complete documentation index, see [llms.txt](https://docs.devolutions.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devolutions.net/powershell-universal/de/apps/components/navigation/stepper.md).

# Stepper

Erstellen Sie mehrstufige Assistenten in PowerShell Universal-Apps mit der Stepper-Komponente, einschließlich Schrittvalidierung, Überspringen und vertikaler Ausrichtung.

**Stepper vermitteln den Fortschritt durch numerierte Schritte. Sie bieten einen assistentenähnlichen Workflow.**

Stepper zeigen den Fortschritt durch eine Abfolge logischer und numerierter Schritte an. Sie können auch zur Navigation verwendet werden. Stepper können nach dem Speichern eines Schritts eine vorübergehende Rückmeldung anzeigen. Der Stepper unterstützt das Speichern von Eingabedaten im Stepper-Kontext. Er unterstützt die folgenden Steuerelemente.

* [Autocomplete](https://docs.devolutions.net/powershell-universal/de/apps/components/inputs/automcomplete.md)
* [Checkbox](https://docs.devolutions.net/powershell-universal/de/apps/components/inputs/checkbox.md)
* [Date Picker](https://docs.devolutions.net/powershell-universal/de/apps/components/inputs/date-picker.md)
* [Radio](https://docs.devolutions.net/powershell-universal/de/apps/components/inputs/radio.md)
* [Select](https://docs.devolutions.net/powershell-universal/de/apps/components/inputs/select.md)
* [Slider](https://docs.devolutions.net/powershell-universal/de/apps/components/inputs/slider.md)
* [Switch](https://docs.devolutions.net/powershell-universal/de/apps/components/inputs/switch.md)
* [Textbox](https://docs.devolutions.net/powershell-universal/de/apps/components/inputs/textbox.md)
* [Time Picker](https://docs.devolutions.net/powershell-universal/de/apps/components/inputs/time-picker.md)
* [Upload](https://docs.devolutions.net/powershell-universal/de/apps/components/inputs/upload.md)

## Stepper

```powershell
New-UDStepper -Steps {
    New-UDStep -OnLoad {
        New-UDElement -tag 'div' -Content { "Step 1" }
        New-UDTextbox -Id 'txtStep1' -Value $EventData.Context.txtStep1
    } -Label "Step 1"
    New-UDStep -OnLoad {
        New-UDElement -tag 'div' -Content { "Step 2" }
        New-UDElement -tag 'div' -Content { "Previous data: $Body" }
        New-UDTextbox -Id 'txtStep2' -Value $EventData.Context.txtStep2
    } -Label "Step 2"
    New-UDStep -OnLoad {
        New-UDElement -tag 'div' -Content { "Step 3" }
        New-UDElement -tag 'div' -Content { "Previous data: $Body" }
        New-UDTextbox -Id 'txtStep3' -Value $EventData.Context.txtStep3
    } -Label "Step 3"
} -OnFinish {
    New-UDTypography -Text 'Nice! You did it!' -Variant h3
    New-UDElement -Tag 'div' -Id 'result' -Content {$Body}
}
```

Die Variable $Body enthält eine JSON-Zeichenfolge mit dem aktuellen Zustand des Steppers. Sie erhalten Informationen über die im Stepper definierten Felder sowie Informationen über den aktuell abgeschlossenen Schritt. Die JSON-Zeichenfolge $Body hat das folgende Format.

```javascript
{
    context: {
        txtStep1: "value1",
        txtStep2: "value2",
        txtStep3: "value3"
    },
    currentStep: 0
}
```

## Einen Schritt validieren

Sie können einen Schritt in einem Stepper validieren, indem Sie den Parameter `OnValidateStep` angeben. Der Skriptblock erhält eine Variable $Body mit JSON, das Informationen über den aktuellen Zustand des Steppers bereitstellt. Sie müssen ein Validierungsergebnis mit `New-UDValidationResult` zurückgeben, um anzugeben, ob der aktuelle Schrittzustand gültig ist.

Die JSON-Nutzlast hat das folgende Format. Beachten Sie, dass Schritte bei 0 beginnen. Wenn Sie den ersten Schritt validieren möchten, prüfen Sie, ob der Schritt 0 ist.

```javascript
{
    context: {
        field1: "value1" 
    },
    currentStep: 0
}
```

Sie müssen die JSON-Zeichenfolge in ein Objekt konvertieren, um in PowerShell damit arbeiten zu können, und dann das Validierungsergebnis zurückgeben.

```powershell
New-UDStepper -Steps {
    New-UDStep -OnLoad {
        New-UDElement -tag 'div' -Content { "Step 1" }
        New-UDTextbox -Id 'txtStep1' -Value $EventData.Context.txtStep1
    } -Label "Step 1"
    New-UDStep -OnLoad {
        New-UDElement -tag 'div' -Content { "Step 2" }
        New-UDElement -tag 'div' -Content { "Previous data: $Body" }
        New-UDTextbox -Id 'txtStep2' -Value $EventData.Context.txtStep2
    } -Label "Step 2"
    New-UDStep -OnLoad {
        New-UDElement -tag 'div' -Content { "Step 3" }
        New-UDElement -tag 'div' -Content { "Previous data: $Body" }
        New-UDTextbox -Id 'txtStep3' -Value $EventData.Context.txtStep3
    } -Label "Step 3"
} -OnFinish {
    New-UDTypography -Text 'Nice! You did it!' -Variant h3
    New-UDElement -Tag 'div' -Id 'result' -Content {$Body}
} -OnValidateStep {
    $Context = $EventData
    if ($Context.CurrentStep -eq 0 -and $Context.Context.txtStep1 -eq 'bad')
    {
        New-UDValidationResult 
    }
    else
    {
        New-UDValidationResult -Valid 
    }
}
```

## Schritte überspringen

Sie können den Benutzer im Event-Handler `OnValidateStep` zu einem bestimmten Schritt leiten. Verwenden Sie den Parameter `-ActiveStep` von `New-UDValidationResult`, um den Benutzer nach einem Klick auf Weiter zu einem beliebigen Schritt zu verschieben. Schrittindizes beginnen bei 0.

In diesem Beispiel wird der Benutzer nach dem Abschluss des ersten Schritts zum letzten Schritt verschoben.

```powershell
New-UDStepper -Steps {
    New-UDStep -OnLoad {
        New-UDElement -tag 'div' -Content { "Step 1" }
        New-UDTextbox -Id 'txtStep1' -Value $EventData.Context.txtStep1
    } -Label "Step 1"
    New-UDStep -OnLoad {
        New-UDElement -tag 'div' -Content { "Step 2" }
        New-UDElement -tag 'div' -Content { "Previous data: $Body" }
        New-UDTextbox -Id 'txtStep2' -Value $EventData.Context.txtStep2
    } -Label "Step 2"
    New-UDStep -OnLoad {
        New-UDElement -tag 'div' -Content { "Step 3" }
        New-UDElement -tag 'div' -Content { "Previous data: $Body" }
        New-UDTextbox -Id 'txtStep3' -Value $EventData.Context.txtStep3
    } -Label "Step 3"
} -OnFinish {
    New-UDTypography -Text 'Nice! You did it!' -Variant h3
    New-UDElement -Tag 'div' -Id 'result' -Content {$Body}
} -OnValidateStep {
    $Context = $EventData
    if ($Context.CurrentStep -eq 0 -and $Context.Context.txtStep1 -eq 'bad')
    {
        New-UDValidationResult 
    }
    else
    {
        New-UDValidationResult -Valid -ActiveStep 2
    }
}
```

## Zurück-Schaltfläche deaktivieren

Sie können die Zurück-Schaltfläche mit dem Parameter `-DisablePrevious` von `New-UDValidationResult` deaktivieren.

In diesem Beispiel wird der vorherige Schritt deaktiviert, sobald der Benutzer im Stepper vorwärts navigiert.

```powershell
New-UDStepper -Steps {
    New-UDStep -OnLoad {
        New-UDElement -tag 'div' -Content { "Step 1" }
        New-UDTextbox -Id 'txtStep1' -Value $EventData.Context.txtStep1
    } -Label "Step 1"
    New-UDStep -OnLoad {
        New-UDElement -tag 'div' -Content { "Step 2" }
        New-UDElement -tag 'div' -Content { "Previous data: $Body" }
        New-UDTextbox -Id 'txtStep2' -Value $EventData.Context.txtStep2
    } -Label "Step 2"
    New-UDStep -OnLoad {
        New-UDElement -tag 'div' -Content { "Step 3" }
        New-UDElement -tag 'div' -Content { "Previous data: $Body" }
        New-UDTextbox -Id 'txtStep3' -Value $EventData.Context.txtStep3
    } -Label "Step 3"
} -OnFinish {
    New-UDTypography -Text 'Nice! You did it!' -Variant h3
    New-UDElement -Tag 'div' -Id 'result' -Content {$Body}
} -OnValidateStep {
    New-UDValidationResult -Valid -DisablePrevious
}
```

## Vertikale Stepper

Sie können einen vertikalen Stepper erstellen, indem Sie den Parameter `-Orientation` auf vertical setzen.

```powershell
New-UDStepper -Steps {
    New-UDStep -OnLoad {
        New-UDElement -tag 'div' -Content { "Step 1" }
        New-UDTextbox -Id 'txtStep1' -Value $EventData.Context.txtStep1
    } -Label "Step 1"
    New-UDStep -OnLoad {
        New-UDElement -tag 'div' -Content { "Step 2" }
        New-UDElement -tag 'div' -Content { "Previous data: $Body" }
        New-UDTextbox -Id 'txtStep2' -Value $EventData.Context.txtStep2
    } -Label "Step 2"
    New-UDStep -OnLoad {
        New-UDElement -tag 'div' -Content { "Step 3" }
        New-UDElement -tag 'div' -Content { "Previous data: $Body" }
        New-UDTextbox -Id 'txtStep3' -Value $EventData.Context.txtStep3
    } -Label "Step 3"
} -OnFinish {
    New-UDTypography -Text 'Nice! You did it!' -Variant h3
    New-UDElement -Tag 'div' -Id 'result' -Content {$Body}
} -Orientation 'vertical'
```

## API

* [New-UDStepper](https://docs.devolutions.net/powershell-universal/de/powershell-befehle/new-udstepper.md)
* [New-UDStep](https://docs.devolutions.net/powershell-universal/de/powershell-befehle/new-udstep.md)
* [New-UDValidationResult](https://docs.devolutions.net/powershell-universal/de/powershell-befehle/new-udvalidationresult.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.devolutions.net/powershell-universal/de/apps/components/navigation/stepper.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
