I want to display a list of files matching a particular expression. I can't figure out how to do it in ShowUI. Please help. Here is my attempt so far.
It is based on the twitter feed example.
Import-Module ShowUI
# use get childchilditem to search recursively for filenames containing the searchstring
function FindMatchingFileNames($searchstring){
gci C:\users\myUser -r -i "*$searchstring*"
}
# variable containing window parameters
$ws = @{
WindowStartupLocation = "CenterScreen"
Height = 550
}
New-Window -SizeToContent width @ws -Show{
ListBox -Background Black -ItemTemplate {
Grid -Columns 300, 300 {
TextBlock -Name FileName -Margin 5 -Column 0 -TextWrapping Wrap -Foreground White
TextBlock -Name FullFileName -Margin 5 -Column 1 -TextWrapping Wrap -Foreground White
} |
ConvertTo-DataTemplate -binding @{
"FileName.Text" = "name"
"FullFileName.Text" = "fullname"
}
} -ItemsSource (FindMatchingFileNames "partial string")
}
|