Closing an UDExpansionPanel dynamically

Hallo EveryOne,

I like to close a UDExpansionPanel dynamically. So I can exclusivly display only one panel of the group. Is there a way to achieve that? As a basic example I tried the following and it did not work at all.


New-UDDashboard -Title 'Expand' -Content {
  New-UDDynamic {
    New-UDTypography -Text "$(Get-Date)"
    New-UDExpansionPanelGroup -Children {
      New-UDExpansionPanel -Title 'Panel1' -Id Panel1 -Active -Children {} 
      New-UDExpansionPanel -Title 'Panel2' -Id Panel2 -Active -Children {}
      New-UDExpansionPanel -Title 'Panel3' -Id Panel3 -Active -Children {} 
    } 
  } -Id 'dyna'
  New-UDButton -Text 'Set NonActive' -OnClick { 
    Set-UDElement -Id 'Panel1' -Properties @{ Active = $false } 
  } 
  New-UDButton -Text 'Sync' -OnClick { Sync-UDElement -Id 'dyna' }
}

What am I doing wrong? Thanks for any help in advance.

Best Regards Z.

Product: PowerShell Universal
Version: 2.12.6

It looks like expansion panel doesn’t implement Set-UDElement properly. You could do something like this.

  New-UDDynamic {
    New-UDTypography -Text "$(Get-Date)"
    New-UDExpansionPanelGroup -Children {
      New-UDExpansionPanel -Title 'Panel1' -Id Panel1 -Active:$Session:Panel1 -Children {} 
      New-UDExpansionPanel -Title 'Panel2' -Id Panel2 -Active:$Session:Panel2 -Children {}
      New-UDExpansionPanel -Title 'Panel3' -Id Panel3 -Active:$Session:Panel3 -Children {} 
    } 
  } -Id 'dyna'
  New-UDButton -Text 'Set NonActive' -OnClick { 
      $Session:Panel1 = $true
      $Session:Panel2 = $false
      $Session:Panel3 = $false
       Sync-UDElement -Id 'dyna'
    
  }