11// Licensed to the .NET Foundation under one or more agreements.
22// The .NET Foundation licenses this file to you under the MIT license.
33
4- using CommunityToolkit . WinUI ;
54using Microsoft . UI . Xaml . Automation . Peers ;
6- using Microsoft . UI . Xaml . Automation ;
75
86namespace Files . App . Controls
97{
108 /// <summary>
119 /// The Blade is used as a child in the BladeView
1210 /// </summary>
1311 [ TemplatePart ( Name = "CloseButton" , Type = typeof ( Button ) ) ]
14- [ TemplatePart ( Name = "EnlargeButton" , Type = typeof ( Button ) ) ]
15- public partial class BladeItem : Expander
12+ public partial class BladeItem : ContentControl
1613 {
1714 private Button _closeButton ;
18- private Button _enlargeButton ;
19- private double _normalModeWidth ;
20- private bool _loaded = false ;
21-
2215 /// <summary>
2316 /// Initializes a new instance of the <see cref="BladeItem"/> class.
2417 /// </summary>
2518 public BladeItem ( )
2619 {
2720 DefaultStyleKey = typeof ( BladeItem ) ;
28-
29- SizeChanged += OnSizeChanged ;
30- Expanding += OnExpanding ;
31- Collapsed += OnCollapsed ;
3221 }
3322
3423 /// <summary>
3524 /// Override default OnApplyTemplate to capture child controls
3625 /// </summary>
3726 protected override void OnApplyTemplate ( )
3827 {
39- _loaded = true ;
28+ base . OnApplyTemplate ( ) ;
4029
4130 _closeButton = GetTemplateChild ( "CloseButton" ) as Button ;
42- _enlargeButton = GetTemplateChild ( "EnlargeButton" ) as Button ;
4331
4432 if ( _closeButton == null )
4533 {
@@ -48,43 +36,7 @@ protected override void OnApplyTemplate()
4836
4937 _closeButton . Click -= CloseButton_Click ;
5038 _closeButton . Click += CloseButton_Click ;
51-
52- if ( _enlargeButton == null )
53- {
54- return ;
55- }
56-
57- _enlargeButton . Click -= EnlargeButton_Click ;
58- _enlargeButton . Click += EnlargeButton_Click ;
59- }
60-
61- /// <inheritdoc/>
62- private void OnExpanding ( Expander sender , ExpanderExpandingEventArgs args )
63- {
64- if ( _loaded )
65- {
66- Width = _normalModeWidth ;
67- VisualStateManager . GoToState ( this , "Expanded" , true ) ;
68- if ( _enlargeButton != null )
69- {
70- AutomationProperties . SetName ( _enlargeButton , "Expand Blade Item" ) ;
71- }
72- }
73- }
74-
75- /// <inheritdoc/>
76- private void OnCollapsed ( Expander sender , ExpanderCollapsedEventArgs args )
77- {
78- if ( _loaded )
79- {
80- Width = double . NaN ;
81- if ( _enlargeButton != null )
82- {
83- AutomationProperties . SetName ( _enlargeButton , "Collapse Blade Item" ) ;
84- }
85- }
8639 }
87-
8840 /// <summary>
8941 /// Creates AutomationPeer (<see cref="UIElement.OnCreateAutomationPeer"/>)
9042 /// </summary>
@@ -94,22 +46,9 @@ protected override AutomationPeer OnCreateAutomationPeer()
9446 return new BladeItemAutomationPeer ( this ) ;
9547 }
9648
97- private void OnSizeChanged ( object sender , SizeChangedEventArgs sizeChangedEventArgs )
98- {
99- if ( IsExpanded )
100- {
101- _normalModeWidth = Width ;
102- }
103- }
104-
10549 private void CloseButton_Click ( object sender , RoutedEventArgs e )
10650 {
10751 IsOpen = false ;
10852 }
109-
110- private void EnlargeButton_Click ( object sender , RoutedEventArgs e )
111- {
112- IsExpanded = ! IsExpanded ;
113- }
11453 }
11554}
0 commit comments