@@ -6,83 +6,168 @@ namespace CommunityToolkit.App.Shared.Controls;
66
77public partial class TitleBar : Control
88{
9- public static readonly DependencyProperty IconProperty = DependencyProperty . Register ( nameof ( Icon ) , typeof ( ImageSource ) , typeof ( TitleBar ) , new PropertyMetadata ( default ( ImageSource ) ) ) ;
10-
9+ /// <summary>
10+ /// The backing <see cref="DependencyProperty"/> for the <see cref="Icon"/> property.
11+ /// </summary>
12+ public static readonly DependencyProperty IconProperty = DependencyProperty . Register ( nameof ( Icon ) , typeof ( IconElement ) , typeof ( TitleBar ) , new PropertyMetadata ( null , IconChanged ) ) ;
13+
14+ /// <summary>
15+ /// The backing <see cref="DependencyProperty"/> for the <see cref="Title"/> property.
16+ /// </summary>
1117 public static readonly DependencyProperty TitleProperty = DependencyProperty . Register ( nameof ( Title ) , typeof ( string ) , typeof ( TitleBar ) , new PropertyMetadata ( default ( string ) ) ) ;
1218
19+ /// <summary>
20+ /// The backing <see cref="DependencyProperty"/> for the <see cref="Subtitle"/> property.
21+ /// </summary>
1322 public static readonly DependencyProperty SubtitleProperty = DependencyProperty . Register ( nameof ( Subtitle ) , typeof ( string ) , typeof ( TitleBar ) , new PropertyMetadata ( default ( string ) ) ) ;
1423
24+ /// <summary>
25+ /// The backing <see cref="DependencyProperty"/> for the <see cref="Content"/> property.
26+ /// </summary>
1527 public static readonly DependencyProperty ContentProperty = DependencyProperty . Register ( nameof ( Content ) , typeof ( object ) , typeof ( TitleBar ) , new PropertyMetadata ( null ) ) ;
1628
29+ /// <summary>
30+ /// The backing <see cref="DependencyProperty"/> for the <see cref="Footer"/> property.
31+ /// </summary>
1732 public static readonly DependencyProperty FooterProperty = DependencyProperty . Register ( nameof ( Footer ) , typeof ( object ) , typeof ( TitleBar ) , new PropertyMetadata ( null ) ) ;
1833
34+ /// <summary>
35+ /// The backing <see cref="DependencyProperty"/> for the <see cref="IsBackButtonVisible"/> property.
36+ /// </summary>
1937 public static readonly DependencyProperty IsBackButtonVisibleProperty = DependencyProperty . Register ( nameof ( IsBackButtonVisible ) , typeof ( bool ) , typeof ( TitleBar ) , new PropertyMetadata ( false , IsBackButtonVisibleChanged ) ) ;
2038
39+ /// <summary>
40+ /// The backing <see cref="DependencyProperty"/> for the <see cref="IsPaneButtonVisible"/> property.
41+ /// </summary>
2142 public static readonly DependencyProperty IsPaneButtonVisibleProperty = DependencyProperty . Register ( nameof ( IsPaneButtonVisible ) , typeof ( bool ) , typeof ( TitleBar ) , new PropertyMetadata ( false , IsPaneButtonVisibleChanged ) ) ;
2243
23- public static readonly DependencyProperty ConfigureTitleBarProperty = DependencyProperty . Register ( nameof ( ConfigureTitleBar ) , typeof ( bool ) , typeof ( TitleBar ) , new PropertyMetadata ( true , ConfigureTitleBarChanged ) ) ;
24-
44+ /// <summary>
45+ /// The backing <see cref="DependencyProperty"/> for the <see cref="Display"/> property.
46+ /// </summary>
2547 public static readonly DependencyProperty DisplayModeProperty = DependencyProperty . Register ( nameof ( DisplayMode ) , typeof ( DisplayMode ) , typeof ( TitleBar ) , new PropertyMetadata ( DisplayMode . Standard , DisplayModeChanged ) ) ;
2648
49+ /// <summary>
50+ /// The backing <see cref="DependencyProperty"/> for the <see cref="CompactStateBreakpoint
51+ /// "/> property.
52+ /// </summary>
53+ public static readonly DependencyProperty CompactStateBreakpointProperty = DependencyProperty . Register ( nameof ( CompactStateBreakpoint ) , typeof ( int ) , typeof ( TitleBar ) , new PropertyMetadata ( 850 ) ) ;
54+
55+ /// <summary>
56+ /// The backing <see cref="DependencyProperty"/> for the <see cref="AutoConfigureCustomTitleBar"/> property.
57+ /// </summary>
58+ public static readonly DependencyProperty AutoConfigureCustomTitleBarProperty = DependencyProperty . Register ( nameof ( AutoConfigureCustomTitleBar ) , typeof ( bool ) , typeof ( TitleBar ) , new PropertyMetadata ( true , AutoConfigureCustomTitleBarChanged ) ) ;
59+
2760#if WINAPPSDK
28- public static readonly DependencyProperty WindowProperty = DependencyProperty . Register ( nameof ( Window ) , typeof ( Window ) , typeof ( TitleBar ) , new PropertyMetadata ( null ) ) ;
61+ /// <summary>
62+ /// The backing <see cref="DependencyProperty"/> for the <see cref="Window"/> property.
63+ /// </summary>
64+ public static readonly DependencyProperty WindowProperty = DependencyProperty . Register ( nameof ( Window ) , typeof ( Window ) , typeof ( TitleBar ) , new PropertyMetadata ( null ) ) ;
2965#endif
3066
31- public ImageSource Icon
67+ /// <summary>
68+ /// The event that gets fired when the back button is clicked
69+ /// </summary>
70+ public event EventHandler < RoutedEventArgs > ? BackButtonClick ;
71+
72+ /// <summary>
73+ /// The event that gets fired when the pane toggle button is clicked
74+ /// </summary>
75+ public event EventHandler < RoutedEventArgs > ? PaneButtonClick ;
76+
77+ /// <summary>
78+ /// Gets or sets the Icon
79+ /// </summary>
80+ public IconElement Icon
3281 {
33- get => ( ImageSource ) GetValue ( IconProperty ) ;
82+ get => ( IconElement ) GetValue ( IconProperty ) ;
3483 set => SetValue ( IconProperty , value ) ;
3584 }
3685
86+ /// <summary>
87+ /// Gets or sets the Title
88+ /// </summary>
3789 public string Title
3890 {
3991 get => ( string ) GetValue ( TitleProperty ) ;
4092 set => SetValue ( TitleProperty , value ) ;
4193 }
4294
95+ /// <summary>
96+ /// Gets or sets the Subtitle
97+ /// </summary>
4398 public string Subtitle
4499 {
45100 get => ( string ) GetValue ( SubtitleProperty ) ;
46101 set => SetValue ( SubtitleProperty , value ) ;
47102 }
48103
104+ /// <summary>
105+ /// Gets or sets the content shown at the center of the TitleBar. When setting this, using DisplayMode=Tall is recommended.
106+ /// </summary>
49107 public object Content
50108 {
51109 get => ( object ) GetValue ( ContentProperty ) ;
52110 set => SetValue ( ContentProperty , value ) ;
53111 }
54112
113+ /// <summary>
114+ /// Gets or sets the content shown at the right of the TitleBar, next to the caption buttons. When setting this, using DisplayMode=Tall is recommended.
115+ /// </summary>
55116 public object Footer
56117 {
57118 get => ( object ) GetValue ( FooterProperty ) ;
58119 set => SetValue ( FooterProperty , value ) ;
59120 }
60121
122+ /// <summary>
123+ /// Gets or sets DisplayMode. Compact is default (32px), Tall is recommended when setting the Content or Footer.
124+ /// </summary>
61125 public DisplayMode DisplayMode
62126 {
63127 get => ( DisplayMode ) GetValue ( DisplayModeProperty ) ;
64128 set => SetValue ( DisplayModeProperty , value ) ;
65129 }
66130
131+ /// <summary>
132+ /// Gets or sets the visibility of the back button.
133+ /// </summary>
67134 public bool IsBackButtonVisible
68135 {
69136 get => ( bool ) GetValue ( IsBackButtonVisibleProperty ) ;
70137 set => SetValue ( IsBackButtonVisibleProperty , value ) ;
71138 }
72139
140+ /// <summary>
141+ /// Gets or sets the visibility of the pane toggle button.
142+ /// </summary>
73143 public bool IsPaneButtonVisible
74144 {
75145 get => ( bool ) GetValue ( IsPaneButtonVisibleProperty ) ;
76146 set => SetValue ( IsPaneButtonVisibleProperty , value ) ;
77147 }
78148
79- public bool ConfigureTitleBar
149+ /// <summary>
150+ /// Gets or sets the breakpoint of when the compact state is triggered.
151+ /// </summary>
152+ public int CompactStateBreakpoint
153+ {
154+ get => ( int ) GetValue ( CompactStateBreakpointProperty ) ;
155+ set => SetValue ( CompactStateBreakpointProperty , value ) ;
156+ }
157+
158+ /// <summary>
159+ /// Gets or sets if the TitleBar should auto configure ExtendContentIntoTitleBar and CaptionButtion background colors.
160+ /// </summary>
161+ public bool AutoConfigureCustomTitleBar
80162 {
81- get => ( bool ) GetValue ( ConfigureTitleBarProperty ) ;
82- set => SetValue ( ConfigureTitleBarProperty , value ) ;
163+ get => ( bool ) GetValue ( AutoConfigureCustomTitleBarProperty ) ;
164+ set => SetValue ( AutoConfigureCustomTitleBarProperty , value ) ;
83165 }
84166
85167#if WINAPPSDK
168+ /// <summary>
169+ /// Gets or sets the window the TitleBar should configure (WASDK only).
170+ /// </summary>
86171 public Window Window
87172 {
88173 get => ( Window ) GetValue ( WindowProperty ) ;
@@ -100,14 +185,26 @@ private static void IsPaneButtonVisibleChanged(DependencyObject d, DependencyPro
100185 ( ( TitleBar ) d ) . Update ( ) ;
101186 }
102187
103- private static void ConfigureTitleBarChanged ( DependencyObject d , DependencyPropertyChangedEventArgs e )
188+ private static void DisplayModeChanged ( DependencyObject d , DependencyPropertyChangedEventArgs e )
104189 {
105- ( ( TitleBar ) d ) . SetTitleBar ( ) ;
190+ ( ( TitleBar ) d ) . Update ( ) ;
106191 }
107192
108- private static void DisplayModeChanged ( DependencyObject d , DependencyPropertyChangedEventArgs e )
193+ private static void IconChanged ( DependencyObject d , DependencyPropertyChangedEventArgs e )
194+ {
195+ ( ( TitleBar ) d ) . Update ( ) ;
196+ }
197+
198+ private static void AutoConfigureCustomTitleBarChanged ( DependencyObject d , DependencyPropertyChangedEventArgs e )
109199 {
110- ( ( TitleBar ) d ) . SetTitleBar ( ) ;
200+ if ( ( ( TitleBar ) d ) . AutoConfigureCustomTitleBar )
201+ {
202+ ( ( TitleBar ) d ) . Configure ( ) ;
203+ }
204+ else
205+ {
206+ ( ( TitleBar ) d ) . Reset ( ) ;
207+ }
111208 }
112209}
113210
0 commit comments