@@ -71,84 +71,89 @@ public partial class TitleBar : TemplatedView, ITitleBar, ISafeAreaView
7171 public static readonly BindableProperty ForegroundColorProperty = BindableProperty . Create ( nameof ( ForegroundColor ) ,
7272 typeof ( Color ) , typeof ( TitleBar ) ) ;
7373
74+ /// <summary>Bindable property for <see cref="TitleFontAttributes"/>.</summary>
75+ public static readonly BindableProperty TitleFontAttributesProperty =
76+ BindableProperty . Create ( nameof ( TitleFontAttributes ) , typeof ( FontAttributes ) ,
77+ typeof ( TitleBar ) , FontAttributes . Bold ) ;
78+
7479 static void OnLeadingChanged ( BindableObject bindable , object oldValue , object newValue )
7580 {
76- var titlebar = ( TitleBar ) bindable ;
81+ var titleBar = ( TitleBar ) bindable ;
7782 if ( newValue is null )
7883 {
79- titlebar . ApplyVisibleState ( LeadingHiddenState ) ;
84+ titleBar . ApplyVisibleState ( LeadingHiddenState ) ;
8085 }
8186 else
8287 {
83- titlebar . ApplyVisibleState ( LeadingVisibleState ) ;
88+ titleBar . ApplyVisibleState ( LeadingVisibleState ) ;
8489 ( newValue as Layout ) ? . IgnoreLayoutSafeArea ( ) ;
8590 }
8691 }
8792
8893 static void OnIconChanged ( BindableObject bindable , object oldValue , object newValue )
8994 {
90- var titlebar = ( TitleBar ) bindable ;
95+ var titleBar = ( TitleBar ) bindable ;
9196 var imageSource = newValue as ImageSource ;
9297 if ( imageSource is null || imageSource . IsEmpty )
9398 {
94- titlebar . ApplyVisibleState ( IconHiddenState ) ;
99+ titleBar . ApplyVisibleState ( IconHiddenState ) ;
95100 }
96101 else
97102 {
98- titlebar . ApplyVisibleState ( IconVisibleState ) ;
103+ titleBar . ApplyVisibleState ( IconVisibleState ) ;
99104 }
100105 }
101106
102107 static void OnTitleChanged ( BindableObject bindable , object oldValue , object newValue )
103108 {
104- var titlebar = ( TitleBar ) bindable ;
109+ var titleBar = ( TitleBar ) bindable ;
105110 if ( newValue is null )
106111 {
107- titlebar . ApplyVisibleState ( TitleHiddenState ) ;
112+ titleBar . ApplyVisibleState ( TitleHiddenState ) ;
108113 }
109114 else
110115 {
111- titlebar . ApplyVisibleState ( TitleVisibleState ) ;
116+ titleBar . ApplyVisibleState ( TitleVisibleState ) ;
112117 }
113118 }
114119
115120 static void OnSubtitleChanged ( BindableObject bindable , object oldValue , object newValue )
116121 {
117- var titlebar = ( TitleBar ) bindable ;
122+ var titleBar = ( TitleBar ) bindable ;
118123 if ( newValue is null )
119124 {
120- titlebar . ApplyVisibleState ( SubtitleHiddenState ) ;
125+ titleBar . ApplyVisibleState ( SubtitleHiddenState ) ;
121126 }
122127 else
123128 {
124- titlebar . ApplyVisibleState ( SubtitleVisibleState ) ;
129+ titleBar . ApplyVisibleState ( SubtitleVisibleState ) ;
125130 }
126131 }
127132
128133 static void OnContentChanged ( BindableObject bindable , object oldValue , object newValue )
129134 {
130- var titlebar = ( TitleBar ) bindable ;
135+ var titleBar = ( TitleBar ) bindable ;
131136 if ( newValue is null )
132137 {
133- titlebar . ApplyVisibleState ( ContentHiddenState ) ;
138+ titleBar . ApplyVisibleState ( ContentHiddenState ) ;
134139 }
135140 else
136141 {
137- titlebar . ApplyVisibleState ( ContentVisibleState ) ;
142+ titleBar . ApplyVisibleState ( ContentVisibleState ) ;
138143 ( newValue as Layout ) ? . IgnoreLayoutSafeArea ( ) ;
139144 }
140145 }
141146
142147 static void OnTrailingContentChanged ( BindableObject bindable , object oldValue , object newValue )
143148 {
144- var titlebar = ( TitleBar ) bindable ;
149+ var titleBar = ( TitleBar ) bindable ;
145150 if ( newValue is null )
146151 {
147- titlebar . ApplyVisibleState ( TrailingHiddenState ) ;
152+ titleBar . ApplyVisibleState ( TrailingHiddenState ) ;
148153 }
149154 else
150155 {
151- titlebar . ApplyVisibleState ( TrailingVisibleState ) ;
156+ titleBar . ApplyVisibleState ( TrailingVisibleState ) ;
152157 ( newValue as Layout ) ? . IgnoreLayoutSafeArea ( ) ;
153158 }
154159 }
@@ -236,6 +241,16 @@ public Color ForegroundColor
236241 set { SetValue ( ForegroundColorProperty , value ) ; }
237242 }
238243
244+ /// <summary>
245+ /// Gets or sets the <see cref="FontAttributes"/> applied to the title text.
246+ /// Defaults to <see cref="FontAttributes.Bold"/>.
247+ /// </summary>
248+ public FontAttributes TitleFontAttributes
249+ {
250+ get => ( FontAttributes ) GetValue ( TitleFontAttributesProperty ) ;
251+ set => SetValue ( TitleFontAttributesProperty , value ) ;
252+ }
253+
239254 /// <inheritdoc/>
240255 public IList < IView > PassthroughElements { get ; private set ; }
241256
@@ -451,6 +466,11 @@ static View BuildDefaultTemplate()
451466 static ( TitleBar tb ) => tb . ForegroundColor ,
452467 source : RelativeBindingSource . TemplatedParent ) ;
453468
469+ titleLabel . SetBinding (
470+ Label . FontAttributesProperty ,
471+ static ( TitleBar tb ) => tb . TitleFontAttributes ,
472+ source : RelativeBindingSource . TemplatedParent ) ;
473+
454474 var activeVisualState = new VisualState ( ) { Name = TitleBarActiveState } ;
455475 activeVisualState . Setters . Add (
456476 new Setter ( )
0 commit comments