| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- function Get-Listbox() {
- cmdlet `
- -DefaultParameterSet Type `
-
- param(
- [Parameter(ParameterSetName="Type", ValueFromPipeline=$true, Mandatory=$true)]
- [Type]
- $type,
- [Parameter(ParameterSetName="Enum", ValueFromPipeline=$true, Mandatory=$true)]
- [Enum]
- $enum,
- [Parameter(ParameterSetName="String", ValueFromPipeline=$true, Mandatory=$true)]
- [string]
- $string
- )
- Begin{
- $listItems = @()
- }
- Process
- {
- switch ($psCmdlet.ParameterSetName) {
- "Type" {
- if ($type.IsEnum) {
- $listItems+= [Enum]::GetValues($type)
- }
- }
- "Enum" {
- $listItems+= [Enum]::GetValues($enum.GetType())
- }
- "String" { $listItems += $string }
- }
- }
-
- End
- {
- $listbox = New-Object Windows.Controls.Listbox
- $listBox.ItemsSource = $listItems | Select -unique
- $listBox
- }
- }
|