Menu New-UDMenu component for Universal Dashboard.
Available in PowerShell Universal 2.5 or later.
The menu component can be used to provide a drop down list of options for the user to select.
Create a basic menu.
Copy New-UDMenu - Content {
New-UDMenuItem - Text 'Item 1'
New-UDMenuItem - Text 'Item 1'
New-UDMenuItem - Text 'Item 1'
}
Button Styles
You can edit the style of the menu by adjusting the variant parameter.
Copy New-UDMenu - Content {
New-UDMenuItem - Text 'Item 1'
New-UDMenuItem - Text 'Item 1'
New-UDMenuItem - Text 'Item 1'
} - Variant outlined
Values
You can use the value parameter to define a value that differs from the text displayed.
Copy New-UDMenu - Content {
New-UDMenuItem - Text 'Item 1' - Value 'item1'
New-UDMenuItem - Text 'Item 1' - Value 'item2'
New-UDMenuItem - Text 'Item 1' - Value 'item3'
}
OnChange Event Handler
Use the -OnChange
parameter to specify a script block to call when a new value is selected. The value of the selected item will be available in $EventData
.
Copy New-UDMenu - Text 'Click Me' - OnChange {
Show-UDToast $EventData
} - Children {
New-UDMenuItem - Text 'Test'
New-UDMenuItem - Text 'Test2'
New-UDMenuItem - Text 'Test3'
}
API