mirror of
https://github.com/rbalsleyMSFT/FFU.git
synced 2026-06-13 18:07:20 -06:00
Fixes header checkbox alignment in grid view
Wraps the "Select All" header checkbox in a custom container to mirror the padding and layout used by data rows. Removes default padding and enforces strict vertical and horizontal centering, ensuring consistent visual alignment between the header and cell content.
This commit is contained in:
@@ -343,7 +343,8 @@ function Add-SelectableGridViewColumn {
|
|||||||
# Create the "Select All" CheckBox for the header
|
# Create the "Select All" CheckBox for the header
|
||||||
$headerCheckBox = New-Object System.Windows.Controls.CheckBox
|
$headerCheckBox = New-Object System.Windows.Controls.CheckBox
|
||||||
$headerCheckBox.HorizontalAlignment = [System.Windows.HorizontalAlignment]::Center
|
$headerCheckBox.HorizontalAlignment = [System.Windows.HorizontalAlignment]::Center
|
||||||
|
$headerCheckBox.VerticalAlignment = [System.Windows.VerticalAlignment]::Center
|
||||||
|
|
||||||
# Store header metadata, including whether select-all should only affect visible rows.
|
# Store header metadata, including whether select-all should only affect visible rows.
|
||||||
$headerTagObject = [PSCustomObject]@{
|
$headerTagObject = [PSCustomObject]@{
|
||||||
PropertyName = $IsSelectedPropertyName
|
PropertyName = $IsSelectedPropertyName
|
||||||
@@ -412,11 +413,33 @@ function Add-SelectableGridViewColumn {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# Wrap the header checkbox in a stretched container so it centers the same way as row cells.
|
||||||
|
# Apply a small left inset to mirror the Fluent ListViewItem content padding used by data rows.
|
||||||
|
$headerBorder = New-Object System.Windows.Controls.Border
|
||||||
|
$headerBorder.Padding = New-Object System.Windows.Thickness(12, 0, 0, 0)
|
||||||
|
$headerBorder.HorizontalAlignment = [System.Windows.HorizontalAlignment]::Stretch
|
||||||
|
$headerBorder.VerticalAlignment = [System.Windows.VerticalAlignment]::Stretch
|
||||||
|
|
||||||
|
$headerGrid = New-Object System.Windows.Controls.Grid
|
||||||
|
$headerGrid.HorizontalAlignment = [System.Windows.HorizontalAlignment]::Stretch
|
||||||
|
$headerGrid.VerticalAlignment = [System.Windows.VerticalAlignment]::Stretch
|
||||||
|
$headerGrid.Children.Add($headerCheckBox) | Out-Null
|
||||||
|
$headerBorder.Child = $headerGrid
|
||||||
|
|
||||||
|
# Use an explicit GridViewColumnHeader so we can remove the default header padding
|
||||||
|
# and control the checkbox alignment explicitly.
|
||||||
|
$selectableHeader = New-Object System.Windows.Controls.GridViewColumnHeader
|
||||||
|
$selectableHeader.HorizontalContentAlignment = [System.Windows.HorizontalAlignment]::Stretch
|
||||||
|
$selectableHeader.VerticalContentAlignment = [System.Windows.VerticalAlignment]::Stretch
|
||||||
|
$selectableHeader.Padding = New-Object System.Windows.Thickness(0)
|
||||||
|
$selectableHeader.Margin = New-Object System.Windows.Thickness(0)
|
||||||
|
$selectableHeader.Content = $headerBorder
|
||||||
|
|
||||||
$State.Controls[$HeaderCheckBoxKeyName] = $headerCheckBox
|
$State.Controls[$HeaderCheckBoxKeyName] = $headerCheckBox
|
||||||
WriteLog "Add-SelectableGridViewColumn: Stored header checkbox in State.Controls with key '$HeaderCheckBoxKeyName'."
|
WriteLog "Add-SelectableGridViewColumn: Stored header checkbox in State.Controls with key '$HeaderCheckBoxKeyName'."
|
||||||
|
|
||||||
$selectableColumn = New-Object System.Windows.Controls.GridViewColumn
|
$selectableColumn = New-Object System.Windows.Controls.GridViewColumn
|
||||||
$selectableColumn.Header = $headerCheckBox
|
$selectableColumn.Header = $selectableHeader
|
||||||
$selectableColumn.Width = $ColumnWidth
|
$selectableColumn.Width = $ColumnWidth
|
||||||
|
|
||||||
$cellTemplate = New-Object System.Windows.DataTemplate
|
$cellTemplate = New-Object System.Windows.DataTemplate
|
||||||
|
|||||||
Reference in New Issue
Block a user