> 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/it/app/components/utilities/dynamic-regions.md).

# Aree dinamiche

`New-UDDynamic` consente di definire una regione dinamica. Le pagine stesse sono dinamiche per natura. Questo significa che ogni volta che una pagina viene caricata, esegue il PowerShell relativo a quella pagina. A volte, potrebbe voler ricaricare una sezione di una pagina anziché l'intera pagina. È in questo caso che vorrà utilizzare le regioni dinamiche.

## Regione dinamica di base

Questa regione dinamica si ricarica quando si fa clic sul pulsante.

```powershell
New-UDApp -Title "Hello, World!" -Content {
    New-UDDynamic -Id 'date' -Content {
        New-UDTypography -Text "$(Get-Date)"
    }

    New-UDButton -Text 'Reload Date' -OnClick { Sync-UDElement -Id 'date' }
}
```

![Reload on button click](/files/9FL18Vvs409Ai5rkKubO)

## Elenco di argomenti

È possibile passare un array di argomenti alla regione dinamica.

```powershell
New-UDDynamic -Id 'dynamic_01' -Content {
    New-UDTypography -Text "This is an $($ArgumentList[0]) an $($ArgumentList[1]) in a UDDynamic"
} -ArgumentList @('example of', 'arguments list') 
```

<figure><img src="/files/B6nUMyas5CjPZZwXeoTd" alt=""><figcaption><p>utilizzando l'elenco di argomenti</p></figcaption></figure>

Può utilizzare `Sync-UDElement` per modificare i valori degli argomenti.

```powershell
 New-UDDynamic -id DynamicRegion -ArgumentList 5,'hello' -content {
  foreach($item in $argumentList){
      New-UDTypography -Variant h3 -Text "Item: $item"
  }
 }

 New-UDButton -Text "Sync Dynamic" -onclick {
  Sync-UDElement -id DynamicRegion -ArgumentList 10,'World'
 }
```

## Aggiornamento automatico

Le regioni dinamiche abilitano la possibilità di aggiornare automaticamente i componenti dopo un determinato periodo di tempo. L'intero blocco di script della regione verrà eseguito durante l'aggiornamento automatico.

{% hint style="info" %}
Se dispone di più componenti correlati che utilizzano gli stessi dati, valuti di inserirli nella stessa regione dinamica per migliorare le prestazioni.
{% endhint %}

```powershell
    New-UDDynamic -Id 'date' -Content {
        New-UDTypography -Text "$(Get-Date)" -Variant h3
        New-UDTypography -Text "$(Get-Random)" -Variant h3
    } -AutoRefresh -AutoRefreshInterval 1
```

![Auto refresh dynamic region](/files/6Hb79Hi5oT4mBUCU9GqL)

## Componente di caricamento

A volte l'aggiornamento di un componente dinamico può richiedere del tempo. Ad esempio, se sta interrogando l'API REST di un altro servizio o dei dati. Le regioni dinamiche supportano la configurazione del componente che viene mostrato durante il ricaricamento della regione. Per impostazione predefinita, non viene mostrato nulla. Può trattarsi di qualsiasi componente dell'app.

```powershell
    New-UDDynamic -Content {
        Start-Sleep -Seconds 3
        New-UDTypography -Text "Done!"
    } -LoadingComponent {
        New-UDProgress -Circular
    }
```

![Loading component for dynamic region](/files/AdfcSJUl4dsDmej7rwwb)

## API

[New-UDDynamic](/powershell-universal/it/comandi-powershell/new-uddynamic.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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.devolutions.net/powershell-universal/it/app/components/utilities/dynamic-regions.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
