@@ -8,34 +8,32 @@ namespace Files.Uwp.UserControls
8
8
{
9
9
public sealed partial class PaneControl : UserControl , IPane
10
10
{
11
- public PanePositions Position { get ; private set ; } = PanePositions . None ;
11
+ private PaneContents content ;
12
12
13
- private IPaneSettingsService PaneService { get ; } = Ioc . Default . GetService < IPaneSettingsService > ( ) ;
13
+ private IPaneSettingsService PaneSettingsService { get ; } = Ioc . Default . GetService < IPaneSettingsService > ( ) ;
14
14
15
- private PaneContents content ;
16
- private Control pane ;
15
+ public PanePositions Position => Panel . Content is IPane pane ? pane . Position : PanePositions . Right ;
17
16
18
17
public PaneControl ( )
19
18
{
20
19
InitializeComponent ( ) ;
21
20
22
- PaneService . PropertyChanged += PaneService_PropertyChanged ;
21
+ PaneSettingsService . PropertyChanged += PaneService_PropertyChanged ;
23
22
Update ( ) ;
24
23
}
25
24
26
25
public void UpdatePosition ( double panelWidth , double panelHeight )
27
26
{
28
- if ( pane is IPane p )
27
+ if ( Panel . Content is IPane pane )
29
28
{
30
- p . UpdatePosition ( panelWidth , panelHeight ) ;
31
- Position = p . Position ;
29
+ pane . UpdatePosition ( panelWidth , panelHeight ) ;
32
30
}
33
- if ( pane is not null )
31
+ if ( Panel . Content is Control control )
34
32
{
35
- MinWidth = pane . MinWidth ;
36
- MaxWidth = pane . MaxWidth ;
37
- MinHeight = pane . MinHeight ;
38
- MaxHeight = pane . MaxHeight ;
33
+ MinWidth = control . MinWidth ;
34
+ MaxWidth = control . MaxWidth ;
35
+ MinHeight = control . MinHeight ;
36
+ MaxHeight = control . MaxHeight ;
39
37
}
40
38
}
41
39
@@ -49,17 +47,11 @@ private void PaneService_PropertyChanged(object sender, PropertyChangedEventArgs
49
47
50
48
private void Update ( )
51
49
{
52
- var newContent = PaneService . Content ;
50
+ var newContent = PaneSettingsService . Content ;
53
51
if ( content != newContent )
54
52
{
55
53
content = newContent ;
56
- pane = GetPane ( content ) ;
57
-
58
- Panel . Children . Clear ( ) ;
59
- if ( pane is not null )
60
- {
61
- Panel . Children . Add ( pane ) ;
62
- }
54
+ Panel . Content = GetPane ( content ) ;
63
55
}
64
56
}
65
57
0 commit comments