11using System . Linq ;
22using Avalonia . Controls ;
33using Avalonia . Controls . Primitives ;
4+ using Avalonia . Controls . Templates ;
45using Avalonia . Input . GestureRecognizers ;
56using Avalonia . Interactivity ;
7+ using Avalonia . Layout ;
68using Avalonia . Media ;
79
810namespace ControlCatalog . Pages
@@ -164,7 +166,7 @@ private void OnShowHeaderToggled(object? sender, RoutedEventArgs e)
164166 if ( ! _isLoaded )
165167 return ;
166168 if ( ShowHeaderCheck . IsChecked == true )
167- DemoDrawer . DrawerHeader = DrawerHeaderBorder ;
169+ DemoDrawer . DrawerHeader = HeaderTemplateCombo . SelectedIndex == 0 ? DrawerHeaderBorder : ( object ) "My Application" ;
168170 else
169171 DemoDrawer . DrawerHeader = null ;
170172 }
@@ -174,9 +176,128 @@ private void OnShowFooterToggled(object? sender, RoutedEventArgs e)
174176 if ( ! _isLoaded )
175177 return ;
176178 if ( ShowFooterCheck . IsChecked == true )
177- DemoDrawer . DrawerFooter = DrawerFooterBorder ;
179+ {
180+ DemoDrawer . DrawerFooter = FooterTemplateCombo . SelectedIndex switch
181+ {
182+ 1 => ( object ) "v12.0" ,
183+ 2 => ( object ) "Avalonia" ,
184+ _ => DrawerFooterBorder
185+ } ;
186+ }
178187 else
188+ {
179189 DemoDrawer . DrawerFooter = null ;
190+ }
191+ }
192+
193+ private void OnHeaderTemplateChanged ( object ? sender , SelectionChangedEventArgs e )
194+ {
195+ if ( ! _isLoaded )
196+ return ;
197+
198+ switch ( HeaderTemplateCombo . SelectedIndex )
199+ {
200+ case 1 :
201+ DemoDrawer . DrawerHeader = "My Application" ;
202+ DemoDrawer . DrawerHeaderTemplate = new FuncDataTemplate < string > ( ( data , _ ) =>
203+ new Border
204+ {
205+ Padding = new Avalonia . Thickness ( 16 ) ,
206+ Child = new StackPanel
207+ {
208+ Spacing = 2 ,
209+ Children =
210+ {
211+ new TextBlock { Text = data , FontSize = 18 , FontWeight = FontWeight . SemiBold , Foreground = Brushes . White } ,
212+ new TextBlock { Text = "Navigation" , FontSize = 12 , Foreground = Brushes . White , Opacity = 0.7 }
213+ }
214+ }
215+ } ) ;
216+ break ;
217+
218+ case 2 :
219+ DemoDrawer . DrawerHeader = "My Application" ;
220+ DemoDrawer . DrawerHeaderTemplate = new FuncDataTemplate < string > ( ( data , _ ) =>
221+ {
222+ var initial = data ? . Length > 0 ? data [ 0 ] . ToString ( ) . ToUpperInvariant ( ) : "?" ;
223+ var avatar = new Border
224+ {
225+ Width = 40 ,
226+ Height = 40 ,
227+ CornerRadius = new Avalonia . CornerRadius ( 20 ) ,
228+ Background = new SolidColorBrush ( Color . Parse ( "#1976D2" ) ) ,
229+ Child = new TextBlock
230+ {
231+ Text = initial ,
232+ FontSize = 18 ,
233+ FontWeight = FontWeight . Bold ,
234+ Foreground = Brushes . White ,
235+ HorizontalAlignment = HorizontalAlignment . Center ,
236+ VerticalAlignment = VerticalAlignment . Center
237+ }
238+ } ;
239+ var label = new TextBlock { Text = data , FontSize = 14 , FontWeight = FontWeight . SemiBold , VerticalAlignment = VerticalAlignment . Center } ;
240+ var row = new StackPanel { Orientation = Orientation . Horizontal , Spacing = 10 } ;
241+ row . Children . Add ( avatar ) ;
242+ row . Children . Add ( label ) ;
243+ return new Border { Padding = new Avalonia . Thickness ( 12 ) , Child = row } ;
244+ } ) ;
245+ break ;
246+
247+ default :
248+ DemoDrawer . DrawerHeader = DrawerHeaderBorder ;
249+ DemoDrawer . DrawerHeaderTemplate = null ;
250+ break ;
251+ }
252+ }
253+
254+ private void OnFooterTemplateChanged ( object ? sender , SelectionChangedEventArgs e )
255+ {
256+ if ( ! _isLoaded )
257+ return ;
258+
259+ switch ( FooterTemplateCombo . SelectedIndex )
260+ {
261+ case 1 :
262+ DemoDrawer . DrawerFooter = "v12.0" ;
263+ DemoDrawer . DrawerFooterTemplate = new FuncDataTemplate < string > ( ( data , _ ) =>
264+ new Border
265+ {
266+ Padding = new Avalonia . Thickness ( 12 , 8 ) ,
267+ Child = new Border
268+ {
269+ Padding = new Avalonia . Thickness ( 8 , 4 ) ,
270+ CornerRadius = new Avalonia . CornerRadius ( 4 ) ,
271+ Background = new SolidColorBrush ( Color . Parse ( "#1976D2" ) ) ,
272+ Child = new TextBlock { Text = data , FontSize = 11 , Foreground = Brushes . White , FontWeight = FontWeight . SemiBold }
273+ }
274+ } ) ;
275+ break ;
276+
277+ case 2 :
278+ DemoDrawer . DrawerFooter = "Avalonia" ;
279+ DemoDrawer . DrawerFooterTemplate = new FuncDataTemplate < string > ( ( data , _ ) =>
280+ {
281+ var icon = new PathIcon
282+ {
283+ Width = 14 ,
284+ Height = 14 ,
285+ Data = Geometry . Parse ( "M13,9H11V7H13M13,17H11V11H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z" ) ,
286+ Opacity = 0.5
287+ } ;
288+ var label = new TextBlock { Text = data , FontSize = 12 , Opacity = 0.6 , VerticalAlignment = VerticalAlignment . Center } ;
289+ var row = new StackPanel { Orientation = Orientation . Horizontal , Spacing = 6 } ;
290+ row . Children . Add ( icon ) ;
291+ row . Children . Add ( label ) ;
292+ return new Border { Padding = new Avalonia . Thickness ( 14 , 10 ) , Child = row } ;
293+ } ) ;
294+ break ;
295+
296+ default :
297+ DemoDrawer . DrawerFooter = DrawerFooterBorder ;
298+ DemoDrawer . DrawerFooterTemplate = null ;
299+ break ;
300+ }
180301 }
181302
182303 private void OnMenuItemClick ( object ? sender , RoutedEventArgs e )
0 commit comments