@@ -14,7 +14,6 @@ namespace CommunityToolkit.WinUI.Controls;
1414
1515[ TemplatePart ( Name = nameof ( PART_FooterPresenter ) , Type = typeof ( ContentPresenter ) ) ]
1616[ TemplatePart ( Name = nameof ( PART_ContentPresenter ) , Type = typeof ( ContentPresenter ) ) ]
17-
1817public partial class TitleBar : Control
1918{
2019 WndProcHelper ? WndProcHelper ;
@@ -55,12 +54,23 @@ private void SetWASDKTitleBar()
5554 } ;
5655 }
5756
57+ // Set the caption buttons to match the flow direction of the titlebar
58+ UpdateCaptionButtonsDirection ( this . FlowDirection ) ;
59+
5860 PART_ContentPresenter = GetTemplateChild ( nameof ( PART_ContentPresenter ) ) as ContentPresenter ;
5961 PART_FooterPresenter = GetTemplateChild ( nameof ( PART_FooterPresenter ) ) as ContentPresenter ;
6062
6163 // Get caption button occlusion information.
6264 int CaptionButtonOcclusionWidthRight = Window . AppWindow . TitleBar . RightInset ;
6365 int CaptionButtonOcclusionWidthLeft = Window . AppWindow . TitleBar . LeftInset ;
66+
67+ // Swap left/right if in RTL mode
68+ if ( this . FlowDirection == FlowDirection . RightToLeft )
69+ {
70+ ( CaptionButtonOcclusionWidthRight , CaptionButtonOcclusionWidthLeft ) = ( CaptionButtonOcclusionWidthLeft , CaptionButtonOcclusionWidthRight ) ;
71+ }
72+
73+ // Set padding columns to match caption button occlusion.
6474 PART_LeftPaddingColumn ! . Width = new GridLength ( CaptionButtonOcclusionWidthLeft ) ;
6575 PART_RightPaddingColumn ! . Width = new GridLength ( CaptionButtonOcclusionWidthRight ) ;
6676
@@ -101,9 +111,6 @@ private void UpdateCaptionButtons(FrameworkElement rootElement)
101111 Window . AppWindow . TitleBar . ButtonForegroundColor = Colors . Black ;
102112 Window . AppWindow . TitleBar . ButtonInactiveForegroundColor = Colors . DarkGray ;
103113 }
104-
105- // Set the caption buttons to match the flow direction of the app
106- UpdateCaptionButtonsDirection ( rootElement . FlowDirection ) ;
107114 }
108115
109116 private void UpdateCaptionButtonsDirection ( FlowDirection direction )
0 commit comments