add error handling

This commit is contained in:
MyDrift 2024-08-22 19:35:02 +02:00
parent 20dc45bc27
commit 7e3d124a24

View File

@ -36,7 +36,11 @@ function Invoke-WPFUIElements {
throw "Failed to retrieve Styles using 'FindResource' from main window element."
}
$targetGrid = $window.FindName($targetGridName)
try {
$targetGrid = $window.FindName($targetGridName)
} catch {
throw "Failed to find the target grid '$targetGridName' in the main window."
}
# Clear existing ColumnDefinitions and Children
$targetGrid.ColumnDefinitions.Clear() | Out-Null