From cd0598c5d196e4c03985176819cc95d4add209ac Mon Sep 17 00:00:00 2001 From: rbalsleyMSFT <53497092+rbalsleyMSFT@users.noreply.github.com> Date: Sat, 15 Feb 2025 11:34:17 -0800 Subject: [PATCH] Fixed a bug displaying USB drives in the listview --- FFUDevelopment/BuildFFUVM_UI.ps1 | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/FFUDevelopment/BuildFFUVM_UI.ps1 b/FFUDevelopment/BuildFFUVM_UI.ps1 index 13c52a4..4e48c58 100644 --- a/FFUDevelopment/BuildFFUVM_UI.ps1 +++ b/FFUDevelopment/BuildFFUVM_UI.ps1 @@ -18,11 +18,11 @@ function Get-USBDrives { $size = [math]::Round($_.Size / 1GB, 2) $serialNumber = if ($_.SerialNumber) { $_.SerialNumber.Trim() } else { "N/A" } @{ - Model = $_.Model + IsSelected = $false + Model = $_.Model.Trim() SerialNumber = $serialNumber Size = $size - DeviceID = $_.DeviceID - IsSelected = $false + DriveIndex = $_.Index } } } @@ -624,14 +624,13 @@ $window.Add_Loaded({ $script:chkSelectAllUSBDrives = $window.FindName('chkSelectAllUSBDrives') $script:btnCheckUSBDrives.Add_Click({ - $usbDrives = Get-USBDrives $script:lstUSBDrives.Items.Clear() + $usbDrives = Get-USBDrives foreach ($drive in $usbDrives) { - [void]$script:lstUSBDrives.Items.Add($drive) + $script:lstUSBDrives.Items.Add([PSCustomObject]$drive) } - - if ($usbDrives.Count -eq 0) { - [System.Windows.MessageBox]::Show("No USB drives found.", "USB Drive Detection", "OK", "Information") + if ($script:lstUSBDrives.Items.Count -gt 0) { + $script:lstUSBDrives.SelectedIndex = 0 } })