From fdb156a4501bd8a9488320e6c09f154f5cfff9c3 Mon Sep 17 00:00:00 2001 From: MyDrift Date: Wed, 2 Oct 2024 08:17:47 +0200 Subject: [PATCH] fix radiobuttons --- functions/public/Invoke-WPFUIElements.ps1 | 19 ++++++++++++++++++- scripts/main.ps1 | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/functions/public/Invoke-WPFUIElements.ps1 b/functions/public/Invoke-WPFUIElements.ps1 index 3ff8bad1..e319d702 100644 --- a/functions/public/Invoke-WPFUIElements.ps1 +++ b/functions/public/Invoke-WPFUIElements.ps1 @@ -59,6 +59,8 @@ function Invoke-WPFUIElements { $configHashtable[$_] = $configVariable.$_ } + $radioButtonGroups = @{} + $organizedData = @{} # Iterate through JSON data and organize by panel and category foreach ($entry in $configHashtable.Keys) { @@ -483,6 +485,20 @@ function Invoke-WPFUIElements { } "RadioButton" { + # Check if a container for this GroupName already exists + if (-not $radioButtonGroups.ContainsKey($entryInfo.GroupName)) { + # Create a StackPanel for this group + $groupStackPanel = New-Object Windows.Controls.StackPanel + $groupStackPanel.Orientation = "Vertical" + + # Add the group container to the ItemsControl + $itemsControl.Items.Add($groupStackPanel) | Out-Null + } else { + # Retrieve the existing group container + $groupStackPanel = $radioButtonGroups[$entryInfo.GroupName] + } + + # Create the RadioButton $radioButton = New-Object Windows.Controls.RadioButton $radioButton.Name = $entryInfo.Name $radioButton.GroupName = $entryInfo.GroupName @@ -496,7 +512,8 @@ function Invoke-WPFUIElements { $radioButton.IsChecked = $true } - $itemsControl.Items.Add($radioButton) | Out-Null + # Add the RadioButton to the group container + $groupStackPanel.Children.Add($radioButton) | Out-Null $sync[$entryInfo.Name] = $radioButton } diff --git a/scripts/main.ps1 b/scripts/main.ps1 index c94b4b1c..169762cb 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -136,8 +136,8 @@ foreach ($category in $uniqueCategories) { # Now call the function with the final merged config Invoke-WPFUIElements -configVariable $sync.configs.appnavigation -targetGridName "appscategory" -columncount 1 - Invoke-WPFUIElements -configVariable $sync.configs.applications -targetGridName "appspanel" -columncount 1 + Invoke-WPFUIElements -configVariable $sync.configs.tweaks -targetGridName "tweakspanel" -columncount 2 Invoke-WPFUIElements -configVariable $sync.configs.feature -targetGridName "featurespanel" -columncount 2