Corrects list view updates to use ItemsSource

Modifies the item lookup logic to query the `ItemsSource` property instead of the `Items` collection.

This ensures changes are applied directly to the underlying data source, leading to more reliable UI updates.
This commit is contained in:
rbalsleyMSFT
2025-06-23 13:44:56 -07:00
parent 84fca7ba25
commit 54dad486a4
@@ -113,7 +113,7 @@ function Update-ListViewItemStatus {
if ($WindowObject -is [System.Windows.Window] -and $ListView -is [System.Windows.Controls.ListView]) { if ($WindowObject -is [System.Windows.Window] -and $ListView -is [System.Windows.Controls.ListView]) {
# Directly update UI elements as this function is now called on the UI thread # Directly update UI elements as this function is now called on the UI thread
try { try {
$itemToUpdate = $ListView.Items | Where-Object { $_.$IdentifierProperty -eq $IdentifierValue } | Select-Object -First 1 $itemToUpdate = $ListView.ItemsSource | Where-Object { $_.$IdentifierProperty -eq $IdentifierValue } | Select-Object -First 1
if ($null -ne $itemToUpdate) { if ($null -ne $itemToUpdate) {
$itemToUpdate.$StatusProperty = $StatusValue $itemToUpdate.$StatusProperty = $StatusValue
$ListView.Items.Refresh() # Refresh the view to show the change $ListView.Items.Refresh() # Refresh the view to show the change