Skip to content

Commit 784b68d

Browse files
authored
Fix: Fixed issue where toolbar buttons were sometimes missing (#18645)
1 parent cb5aa2d commit 784b68d

5 files changed

Lines changed: 10 additions & 15 deletions

File tree

src/Files.App/UserControls/Toolbar.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
x:Name="SelectionOptions"
112112
Width="Auto"
113113
MinWidth="46"
114-
x:Load="{x:Bind ShowViewControlButton, Mode=OneWay}"
114+
x:Load="{x:Bind ViewModel.InstanceViewModel.IsPageTypeNotHome, Mode=OneWay}"
115115
AccessKey="S"
116116
AccessKeyInvoked="AppBarButton_AccessKeyInvoked"
117117
AutomationProperties.Name="{helpers:ResourceString Name=SelectionOptions}"
@@ -155,7 +155,7 @@
155155
x:Name="ArrangementOptions"
156156
Width="Auto"
157157
MinWidth="46"
158-
x:Load="{x:Bind ShowViewControlButton, Mode=OneWay}"
158+
x:Load="{x:Bind ViewModel.InstanceViewModel.IsPageTypeNotHome, Mode=OneWay}"
159159
AccessKey="A"
160160
AccessKeyInvoked="AppBarButton_AccessKeyInvoked"
161161
AutomationProperties.Name="{helpers:ResourceString Name=Sort}"
@@ -266,7 +266,7 @@
266266
x:Name="LayoutOptionsButton"
267267
Width="Auto"
268268
MinWidth="46"
269-
x:Load="{x:Bind ShowViewControlButton, Mode=OneWay}"
269+
x:Load="{x:Bind ViewModel.InstanceViewModel.IsPageTypeNotHome, Mode=OneWay}"
270270
AccessKey="L"
271271
AccessKeyInvoked="AppBarButton_AccessKeyInvoked"
272272
AutomationProperties.Name="{helpers:ResourceString Name=Layout}"

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ public sealed partial class Toolbar : UserControl
3131
[GeneratedDependencyProperty]
3232
public partial NavigationToolbarViewModel? ViewModel { get; set; }
3333

34-
[GeneratedDependencyProperty]
35-
public partial bool ShowViewControlButton { get; set; }
36-
3734
[GeneratedDependencyProperty]
3835
public partial bool ShowPreviewPaneButton { get; set; }
3936

src/Files.App/ViewModels/MainPageViewModel.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,6 @@ public TabBarItem? SelectedTabItem
6060
set => SetProperty(ref selectedTabItem, value);
6161
}
6262

63-
private bool shouldViewControlBeDisplayed;
64-
public bool ShouldViewControlBeDisplayed
65-
{
66-
get => shouldViewControlBeDisplayed;
67-
set => SetProperty(ref shouldViewControlBeDisplayed, value);
68-
}
69-
7063
private bool shouldPreviewPaneBeActive;
7164
public bool ShouldPreviewPaneBeActive
7265
{

src/Files.App/Views/MainPage.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@
227227
x:Load="False"
228228
Loaded="NavToolbar_Loaded"
229229
ShowPreviewPaneButton="{x:Bind ViewModel.ShouldPreviewPaneBeDisplayed, Mode=OneWay}"
230-
ShowViewControlButton="{x:Bind ViewModel.ShouldViewControlBeDisplayed, Mode=OneWay}"
231230
TabIndex="2"
232231
Visibility="{x:Bind ViewModel.ShowToolbar, Mode=OneWay}" />
233232

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public MainPage()
5656

5757
ViewModel.PropertyChanged += ViewModel_PropertyChanged;
5858
UserSettingsService.OnSettingChangedEvent += UserSettingsService_OnSettingChangedEvent;
59+
ContentPageContext.PropertyChanged += ContentPageContext_PropertyChanged;
5960

6061
_updateDateDisplayTimer = DispatcherQueue.CreateTimer();
6162
_updateDateDisplayTimer.Interval = TimeSpan.FromSeconds(1);
@@ -188,6 +189,12 @@ private void PaneHolder_PropertyChanged(object? sender, PropertyChangedEventArgs
188189
LoadPaneChanged();
189190
}
190191

192+
private void ContentPageContext_PropertyChanged(object? sender, PropertyChangedEventArgs e)
193+
{
194+
if (e.PropertyName is nameof(IContentPageContext.PageType))
195+
LoadPaneChanged();
196+
}
197+
191198
private void UpdateStatusBarProperties()
192199
{
193200
if (StatusBar is not null)
@@ -420,7 +427,6 @@ private void LoadPaneChanged()
420427

421428
ViewModel.ShouldPreviewPaneBeDisplayed = ((!isHomePage && !isReleaseNotesPage && !isSettingsPage) || isMultiPane) && isBigEnough;
422429
ViewModel.ShouldPreviewPaneBeActive = UserSettingsService.InfoPaneSettingsService.IsInfoPaneEnabled && ViewModel.ShouldPreviewPaneBeDisplayed;
423-
ViewModel.ShouldViewControlBeDisplayed = SidebarAdaptiveViewModel.PaneHolder?.ActivePane?.InstanceViewModel?.IsPageTypeNotHome ?? false;
424430

425431
UpdatePositioning();
426432
}

0 commit comments

Comments
 (0)