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

@ -7,7 +7,7 @@
"Description": "Toggle between a list and a compact grid like view"
},
"WPFSelectedFilter": {
"Content": ["Show Selected", "Show All"],
"Content": [ "Show All", "Show Selected"],
"Category": "____Actions",
"Type": "ToggleButton",
"Order": "2",

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

View File

@ -360,9 +360,9 @@
<Ellipse x:Name="ToggleDot"
Width="8" Height="8"
Fill="{DynamicResource ButtonForegroundColor}"
HorizontalAlignment="Left"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Margin="5,3,0,0" />
Margin="0,3,5,0" />
<!-- Content Presenter -->
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10,2,10,2"/>
@ -374,7 +374,7 @@
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="ToggleDot" Property="VerticalAlignment" Value="Bottom"/>
<Setter TargetName="ToggleDot" Property="Margin" Value="5,0,0,3"/> <!-- Consistent bottom margin -->
<Setter TargetName="ToggleDot" Property="Margin" Value="0,0,5,3"/> <!-- Consistent bottom margin on the right -->
</Trigger>
<Trigger Property="IsPressed" Value="True">