Skip to content

Commit 6df8569

Browse files
authored
Fix: Fixed crash that would occur when adding a new tab (#12840)
1 parent 3e553a6 commit 6df8569

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

src/Files.App/UserControls/InnerNavigationToolbar.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@
443443
x:Name="SelectionOptions"
444444
Width="Auto"
445445
MinWidth="40"
446-
x:Load="{x:Bind ViewModel.InstanceViewModel.IsPageTypeNotHome, Mode=OneWay}"
446+
x:Load="{x:Bind ShowViewControlButton, Mode=OneWay}"
447447
AccessKey="S"
448448
AutomationProperties.Name="{helpers:ResourceString Name=SelectionOptions}"
449449
Label="{helpers:ResourceString Name=NavToolbarSelectionOptions/Label}"
@@ -486,7 +486,7 @@
486486
x:Name="ArrangementOptions"
487487
Width="Auto"
488488
MinWidth="40"
489-
x:Load="{x:Bind ViewModel.InstanceViewModel.IsPageTypeNotHome, Mode=OneWay}"
489+
x:Load="{x:Bind ShowViewControlButton, Mode=OneWay}"
490490
AccessKey="A"
491491
AutomationProperties.Name="{helpers:ResourceString Name=Sort}"
492492
Label="{helpers:ResourceString Name=Sort}"
@@ -590,7 +590,7 @@
590590
x:Name="LayoutOptionsButton"
591591
Width="Auto"
592592
MinWidth="40"
593-
x:Load="{x:Bind ViewModel.InstanceViewModel.IsPageTypeNotHome, Mode=OneWay}"
593+
x:Load="{x:Bind ShowViewControlButton, Mode=OneWay}"
594594
AccessKey="L"
595595
AutomationProperties.Name="{helpers:ResourceString Name=Layout}"
596596
Label="{helpers:ResourceString Name=Layout}"

src/Files.App/UserControls/InnerNavigationToolbar.xaml.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ public ToolbarViewModel ViewModel
4040
public static readonly DependencyProperty ViewModelProperty =
4141
DependencyProperty.Register(nameof(ViewModel), typeof(ToolbarViewModel), typeof(InnerNavigationToolbar), new PropertyMetadata(null));
4242

43+
public bool ShowViewControlButton
44+
{
45+
get { return (bool)GetValue(ShowViewControlButtonProperty); }
46+
set { SetValue(ShowViewControlButtonProperty, value); }
47+
}
48+
49+
// Using a DependencyProperty as the backing store for ShowViewControlButton. This enables animation, styling, binding, etc...
50+
public static readonly DependencyProperty ShowViewControlButtonProperty =
51+
DependencyProperty.Register("ShowViewControlButton", typeof(bool), typeof(AddressToolbar), new PropertyMetadata(null));
52+
4353
public bool ShowPreviewPaneButton
4454
{
4555
get { return (bool)GetValue(ShowPreviewPaneButtonProperty); }

src/Files.App/Views/MainPage.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@
218218
x:Load="False"
219219
Loaded="NavToolbar_Loaded"
220220
ShowPreviewPaneButton="{x:Bind ShouldPreviewPaneBeDisplayed, Mode=OneWay}"
221+
ShowViewControlButton="{x:Bind ShouldViewControlBeDisplayed, Mode=OneWay}"
221222
TabIndex="2" />
222223

223224
<!-- Page Content -->

src/Files.App/Views/MainPage.xaml.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,8 @@ private void PaneSplitter_ManipulationCompleted(object sender, ManipulationCompl
484484
this.ChangeCursor(InputSystemCursor.Create(InputSystemCursorShape.Arrow));
485485
}
486486

487+
public bool ShouldViewControlBeDisplayed => SidebarAdaptiveViewModel.PaneHolder?.ActivePane?.InstanceViewModel?.IsPageTypeNotHome ?? false;
488+
487489
public bool ShouldPreviewPaneBeActive => UserSettingsService.PreviewPaneSettingsService.IsEnabled && ShouldPreviewPaneBeDisplayed;
488490

489491
public bool ShouldPreviewPaneBeDisplayed
@@ -501,6 +503,7 @@ public bool ShouldPreviewPaneBeDisplayed
501503

502504
private void LoadPaneChanged()
503505
{
506+
OnPropertyChanged(nameof(ShouldViewControlBeDisplayed));
504507
OnPropertyChanged(nameof(ShouldPreviewPaneBeActive));
505508
OnPropertyChanged(nameof(ShouldPreviewPaneBeDisplayed));
506509
UpdatePositioning();

0 commit comments

Comments
 (0)