diff --git a/functions/public/Invoke-WPFButton.ps1 b/functions/public/Invoke-WPFButton.ps1
index 684d31c4..80771a90 100644
--- a/functions/public/Invoke-WPFButton.ps1
+++ b/functions/public/Invoke-WPFButton.ps1
@@ -85,12 +85,12 @@ function Invoke-WPFButton {
}
}
"WPFCloseButton" {$sync.Form.Close(); Write-Host "Bye bye!"}
- "WPFMinimizeButton" {$sync.Form.WindowState = [Windows.WindowState]::Minimized}
+ "WPFMinimizeButton" {[Windows.SystemCommands]::MinimizeWindow($sync.Form)}
"WPFMaximizeButton" {
if ($sync.Form.WindowState -eq [Windows.WindowState]::Normal) {
- $sync.Form.WindowState = [Windows.WindowState]::Maximized
+ [Windows.SystemCommands]::MaximizeWindow($sync.Form)
} else {
- $sync.Form.WindowState = [Windows.WindowState]::Normal
+ [Windows.SystemCommands]::RestoreWindow($sync.Form)
}
}
"WPFselectedAppsButton" {$sync.selectedAppsPopup.IsOpen = -not $sync.selectedAppsPopup.IsOpen}
diff --git a/pester/ui-state.Tests.ps1 b/pester/ui-state.Tests.ps1
index 31a2af37..5223601a 100644
--- a/pester/ui-state.Tests.ps1
+++ b/pester/ui-state.Tests.ps1
@@ -445,31 +445,3 @@ Describe "Invoke-WPFButton progress cleanup" {
}
}
-Describe "Invoke-WPFButton window state" {
- BeforeEach {
- New-WinUtilUiStateTestContext
- $script:sync.ProcessRunning = $true
- $script:sync.Form = [pscustomobject]@{
- WindowState = [Windows.WindowState]::Normal
- }
- }
-
- AfterEach {
- Remove-Variable -Name sync -Scope Script -ErrorAction SilentlyContinue
- Remove-Variable -Name sync -Scope Global -ErrorAction SilentlyContinue
- }
-
- It "maximizes a normal window" {
- Invoke-WPFButton -Button "WPFMaximizeButton"
-
- $script:sync.Form.WindowState | Should -Be ([Windows.WindowState]::Maximized)
- }
-
- It "restores a maximized window" {
- $script:sync.Form.WindowState = [Windows.WindowState]::Maximized
-
- Invoke-WPFButton -Button "WPFMaximizeButton"
-
- $script:sync.Form.WindowState | Should -Be ([Windows.WindowState]::Normal)
- }
-}
diff --git a/scripts/main.ps1 b/scripts/main.ps1
index 23f42f52..887b1e26 100644
--- a/scripts/main.ps1
+++ b/scripts/main.ps1
@@ -252,10 +252,10 @@ $sync["Form"].Add_MouseDoubleClick({
if ($_.OriginalSource.Name -eq "NavDockPanel" -or
$_.OriginalSource.Name -eq "GridBesideNavDockPanel") {
if ($sync["Form"].WindowState -eq [Windows.WindowState]::Normal) {
- $sync["Form"].WindowState = [Windows.WindowState]::Maximized
+ [Windows.SystemCommands]::MaximizeWindow($sync.Form)
}
else{
- $sync["Form"].WindowState = [Windows.WindowState]::Normal
+ [Windows.SystemCommands]::RestoreWindow($sync.Form)
}
}
})
diff --git a/xaml/inputXML.xaml b/xaml/inputXML.xaml
index 273ae5a2..30994e75 100644
--- a/xaml/inputXML.xaml
+++ b/xaml/inputXML.xaml
@@ -13,7 +13,7 @@
MinHeight="600"
Title="WinUtil">
-
+