diff --git a/functions/public/Invoke-WPFUIElements.ps1 b/functions/public/Invoke-WPFUIElements.ps1 index 47531c4c..240cbd62 100644 --- a/functions/public/Invoke-WPFUIElements.ps1 +++ b/functions/public/Invoke-WPFUIElements.ps1 @@ -404,6 +404,27 @@ function Invoke-WPFUIElements { $textBlock.ToolTip = $entryInfo.Link $textBlock.Style = $HoverTextBlockStyle $textBlock.UseLayoutRounding = $true + + $textBlock.VerticalAlignment = "Center" + $textBlock.SetResourceReference([Windows.Controls.Control]::FontSizeProperty, "FontSize") + $textBlock.Tag = $checkBox + + $updateLinkMargin = { + [System.Object]$Sender = $args[0] + $linkedCheckBox = $Sender.Tag + $MarginTopBase = if ($linkedCheckBox) { $linkedCheckBox.Margin.Top } else { 0 } + $Sender.Margin = New-Object Windows.Thickness( + [math]::Round($Sender.FontSize * 0.5), + ($MarginTopBase - [math]::Round($Sender.FontSize / 2)), + 0, 0 + ) + } + $textBlock.Add_Loaded($updateLinkMargin) + $fontSizeDescriptor = [System.ComponentModel.DependencyPropertyDescriptor]::FromProperty( + [Windows.Controls.Control]::FontSizeProperty, + [Windows.Controls.TextBlock] + ) + $fontSizeDescriptor.AddValueChanged($textBlock, $updateLinkMargin) $horizontalStackPanel.Children.Add($textBlock) | Out-Null