@@ -6,83 +6,168 @@ namespace CommunityToolkit.App.Shared.Controls;
6
6
7
7
public partial class TitleBar : Control
8
8
{
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>
11
17
public static readonly DependencyProperty TitleProperty = DependencyProperty . Register ( nameof ( Title ) , typeof ( string ) , typeof ( TitleBar ) , new PropertyMetadata ( default ( string ) ) ) ;
12
18
19
+ /// <summary>
20
+ /// The backing <see cref="DependencyProperty"/> for the <see cref="Subtitle"/> property.
21
+ /// </summary>
13
22
public static readonly DependencyProperty SubtitleProperty = DependencyProperty . Register ( nameof ( Subtitle ) , typeof ( string ) , typeof ( TitleBar ) , new PropertyMetadata ( default ( string ) ) ) ;
14
23
24
+ /// <summary>
25
+ /// The backing <see cref="DependencyProperty"/> for the <see cref="Content"/> property.
26
+ /// </summary>
15
27
public static readonly DependencyProperty ContentProperty = DependencyProperty . Register ( nameof ( Content ) , typeof ( object ) , typeof ( TitleBar ) , new PropertyMetadata ( null ) ) ;
16
28
29
+ /// <summary>
30
+ /// The backing <see cref="DependencyProperty"/> for the <see cref="Footer"/> property.
31
+ /// </summary>
17
32
public static readonly DependencyProperty FooterProperty = DependencyProperty . Register ( nameof ( Footer ) , typeof ( object ) , typeof ( TitleBar ) , new PropertyMetadata ( null ) ) ;
18
33
34
+ /// <summary>
35
+ /// The backing <see cref="DependencyProperty"/> for the <see cref="IsBackButtonVisible"/> property.
36
+ /// </summary>
19
37
public static readonly DependencyProperty IsBackButtonVisibleProperty = DependencyProperty . Register ( nameof ( IsBackButtonVisible ) , typeof ( bool ) , typeof ( TitleBar ) , new PropertyMetadata ( false , IsBackButtonVisibleChanged ) ) ;
20
38
39
+ /// <summary>
40
+ /// The backing <see cref="DependencyProperty"/> for the <see cref="IsPaneButtonVisible"/> property.
41
+ /// </summary>
21
42
public static readonly DependencyProperty IsPaneButtonVisibleProperty = DependencyProperty . Register ( nameof ( IsPaneButtonVisible ) , typeof ( bool ) , typeof ( TitleBar ) , new PropertyMetadata ( false , IsPaneButtonVisibleChanged ) ) ;
22
43
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>
25
47
public static readonly DependencyProperty DisplayModeProperty = DependencyProperty . Register ( nameof ( DisplayMode ) , typeof ( DisplayMode ) , typeof ( TitleBar ) , new PropertyMetadata ( DisplayMode . Standard , DisplayModeChanged ) ) ;
26
48
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
+
27
60
#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 ) ) ;
29
65
#endif
30
66
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
32
81
{
33
- get => ( ImageSource ) GetValue ( IconProperty ) ;
82
+ get => ( IconElement ) GetValue ( IconProperty ) ;
34
83
set => SetValue ( IconProperty , value ) ;
35
84
}
36
85
86
+ /// <summary>
87
+ /// Gets or sets the Title
88
+ /// </summary>
37
89
public string Title
38
90
{
39
91
get => ( string ) GetValue ( TitleProperty ) ;
40
92
set => SetValue ( TitleProperty , value ) ;
41
93
}
42
94
95
+ /// <summary>
96
+ /// Gets or sets the Subtitle
97
+ /// </summary>
43
98
public string Subtitle
44
99
{
45
100
get => ( string ) GetValue ( SubtitleProperty ) ;
46
101
set => SetValue ( SubtitleProperty , value ) ;
47
102
}
48
103
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>
49
107
public object Content
50
108
{
51
109
get => ( object ) GetValue ( ContentProperty ) ;
52
110
set => SetValue ( ContentProperty , value ) ;
53
111
}
54
112
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>
55
116
public object Footer
56
117
{
57
118
get => ( object ) GetValue ( FooterProperty ) ;
58
119
set => SetValue ( FooterProperty , value ) ;
59
120
}
60
121
122
+ /// <summary>
123
+ /// Gets or sets DisplayMode. Compact is default (32px), Tall is recommended when setting the Content or Footer.
124
+ /// </summary>
61
125
public DisplayMode DisplayMode
62
126
{
63
127
get => ( DisplayMode ) GetValue ( DisplayModeProperty ) ;
64
128
set => SetValue ( DisplayModeProperty , value ) ;
65
129
}
66
130
131
+ /// <summary>
132
+ /// Gets or sets the visibility of the back button.
133
+ /// </summary>
67
134
public bool IsBackButtonVisible
68
135
{
69
136
get => ( bool ) GetValue ( IsBackButtonVisibleProperty ) ;
70
137
set => SetValue ( IsBackButtonVisibleProperty , value ) ;
71
138
}
72
139
140
+ /// <summary>
141
+ /// Gets or sets the visibility of the pane toggle button.
142
+ /// </summary>
73
143
public bool IsPaneButtonVisible
74
144
{
75
145
get => ( bool ) GetValue ( IsPaneButtonVisibleProperty ) ;
76
146
set => SetValue ( IsPaneButtonVisibleProperty , value ) ;
77
147
}
78
148
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
80
162
{
81
- get => ( bool ) GetValue ( ConfigureTitleBarProperty ) ;
82
- set => SetValue ( ConfigureTitleBarProperty , value ) ;
163
+ get => ( bool ) GetValue ( AutoConfigureCustomTitleBarProperty ) ;
164
+ set => SetValue ( AutoConfigureCustomTitleBarProperty , value ) ;
83
165
}
84
166
85
167
#if WINAPPSDK
168
+ /// <summary>
169
+ /// Gets or sets the window the TitleBar should configure (WASDK only).
170
+ /// </summary>
86
171
public Window Window
87
172
{
88
173
get => ( Window ) GetValue ( WindowProperty ) ;
@@ -100,14 +185,26 @@ private static void IsPaneButtonVisibleChanged(DependencyObject d, DependencyPro
100
185
( ( TitleBar ) d ) . Update ( ) ;
101
186
}
102
187
103
- private static void ConfigureTitleBarChanged ( DependencyObject d , DependencyPropertyChangedEventArgs e )
188
+ private static void DisplayModeChanged ( DependencyObject d , DependencyPropertyChangedEventArgs e )
104
189
{
105
- ( ( TitleBar ) d ) . SetTitleBar ( ) ;
190
+ ( ( TitleBar ) d ) . Update ( ) ;
106
191
}
107
192
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 )
109
199
{
110
- ( ( TitleBar ) d ) . SetTitleBar ( ) ;
200
+ if ( ( ( TitleBar ) d ) . AutoConfigureCustomTitleBar )
201
+ {
202
+ ( ( TitleBar ) d ) . Configure ( ) ;
203
+ }
204
+ else
205
+ {
206
+ ( ( TitleBar ) d ) . Reset ( ) ;
207
+ }
111
208
}
112
209
}
113
210
0 commit comments