@@ -14,7 +14,6 @@ namespace CommunityToolkit.WinUI.Controls;
14
14
15
15
[ TemplatePart ( Name = nameof ( PART_FooterPresenter ) , Type = typeof ( ContentPresenter ) ) ]
16
16
[ TemplatePart ( Name = nameof ( PART_ContentPresenter ) , Type = typeof ( ContentPresenter ) ) ]
17
-
18
17
public partial class TitleBar : Control
19
18
{
20
19
WndProcHelper ? WndProcHelper ;
@@ -55,12 +54,23 @@ private void SetWASDKTitleBar()
55
54
} ;
56
55
}
57
56
57
+ // Set the caption buttons to match the flow direction of the titlebar
58
+ UpdateCaptionButtonsDirection ( this . FlowDirection ) ;
59
+
58
60
PART_ContentPresenter = GetTemplateChild ( nameof ( PART_ContentPresenter ) ) as ContentPresenter ;
59
61
PART_FooterPresenter = GetTemplateChild ( nameof ( PART_FooterPresenter ) ) as ContentPresenter ;
60
62
61
63
// Get caption button occlusion information.
62
64
int CaptionButtonOcclusionWidthRight = Window . AppWindow . TitleBar . RightInset ;
63
65
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.
64
74
PART_LeftPaddingColumn ! . Width = new GridLength ( CaptionButtonOcclusionWidthLeft ) ;
65
75
PART_RightPaddingColumn ! . Width = new GridLength ( CaptionButtonOcclusionWidthRight ) ;
66
76
@@ -101,9 +111,6 @@ private void UpdateCaptionButtons(FrameworkElement rootElement)
101
111
Window . AppWindow . TitleBar . ButtonForegroundColor = Colors . Black ;
102
112
Window . AppWindow . TitleBar . ButtonInactiveForegroundColor = Colors . DarkGray ;
103
113
}
104
-
105
- // Set the caption buttons to match the flow direction of the app
106
- UpdateCaptionButtonsDirection ( rootElement . FlowDirection ) ;
107
114
}
108
115
109
116
private void UpdateCaptionButtonsDirection ( FlowDirection direction )
0 commit comments