Togglebutton fixes

- move dot to the right in style
- cleanup code
- fix arrangement of content
This commit is contained in:
MyDrift
2024-10-26 15:25:33 +02:00
parent fd4d783a04
commit c0d6e0bbc7
4 changed files with 11 additions and 24 deletions

View File

@ -121,7 +121,7 @@ function Show-OnlyCheckedApps {
$_.Content = "Show Selected"
}
Set-CategoryVisibility -Category "*" -ItemsControl $ItemsControl -automaticVisibility
}
}
}
function Invoke-WPFUIApps {

View File

@ -194,29 +194,16 @@ function Invoke-WPFUIElements {
}
"ToggleButton" {
# Determine contentOn and contentOff based on the Content property
if ($entryInfo.Content -is [array]) {
# If Content is an array, use its elements
write-host "Content is an array"
write-host $entryInfo.Content
$contentOn = if ($entryInfo.Content.Count -ge 1) { $entryInfo.Content[0] } else { "" }
$contentOff = if ($entryInfo.Content.Count -ge 2) { $entryInfo.Content[1] } else { $contentOn }
} else {
# If Content is a single value, use it for both states
$contentOn = $entryInfo.Content
$contentOff = $entryInfo.Content
}
$toggleButton = New-Object Windows.Controls.Primitives.ToggleButton
$toggleButton.Name = $entryInfo.Name
$toggleButton.Content = $contentOff
$toggleButton.Content = $entryInfo.Content[1]
$toggleButton.ToolTip = $entryInfo.Description
$toggleButton.HorizontalAlignment = "Left"
$toggleButton.Style = $ToggleButtonStyle
$toggleButton.Tag = @{
contentOn = $contentOn
contentOff = $contentOff
contentOn = if ($entryInfo.Content.Count -ge 1) { $entryInfo.Content[0] } else { "" }
contentOff = if ($entryInfo.Content.Count -ge 2) { $entryInfo.Content[1] } else { $contentOn }
}
$itemsControl.Items.Add($toggleButton) | Out-Null