-
Notifications
You must be signed in to change notification settings - Fork 64
/
ConvertTo-DataGrid-ShowUI.ps1
35 lines (32 loc) · 1.37 KB
/
ConvertTo-DataGrid-ShowUI.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function ConvertTo-DataGrid {
[CmdletBinding()]
param(
[Parameter(ValueFromPipeline=$True, ParameterSetName="Dictionary", Position=0, Mandatory=$True)]
[Collections.IDictionary]$Dictionary,
[Parameter(ValueFromPipeline=$True, ParameterSetName="InputObject", Position=0, Mandatory=$True)]
$InputObject,
[Switch]$IsReadOnly,
[Switch]$IsDisabled
)
process {
# UniformGrid -Columns 2 {
DataGrid -IsReadOnly:$IsReadOnly -IsEnabled:(!$IsDisabled) -HeadersVisibility "None" -ItemsSource @(
if($InputObject) {
$InputObject = Select-Object * -InputObject $InputObject
foreach($member in Get-Member -InputObject $InputObject -Type NoteProperty) {
New-Object PSObject -Property ([ordered]@{
Field = $member.Name
Value = $InputObject.($Member.Name)
})
}
} else {
foreach($kv in $Dictionary.GetEnumerator()) {
New-Object PSObject -Property ([ordered]@{
Field = $kv.Key
Value = $kv.Value
})
}
}
) -Show
}
}