Skip to content

Commit e96cc99

Browse files
authored
Fixed a bug where "empty recycle bin" was not grayed when recycle bin is empty (#1667)
1 parent c92332a commit e96cc99

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

Files/UserControls/SidebarControl.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@
295295
x:Name="EmptyRecycleBin"
296296
x:Uid="BaseLayoutContextFlyoutEmptyRecycleBin"
297297
x:Load="{x:Bind ShowEmptyRecycleBin, Mode=OneWay}"
298+
IsEnabled="{x:Bind RecycleBinHasItems, Mode=OneWay}"
298299
Click="{x:Bind local1:App.CurrentInstance.InteractionOperations.EmptyRecycleBin_ClickAsync}"
299300
Text="Empty recycle bin">
300301
<MenuFlyoutItem.Icon>

Files/UserControls/SidebarControl.xaml.cs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.IO;
77
using System.Runtime.CompilerServices;
88
using Windows.ApplicationModel.DataTransfer;
9+
using Windows.Foundation.Collections;
910
using Windows.UI.Xaml;
1011
using Windows.UI.Xaml.Controls;
1112
using Windows.UI.Xaml.Input;
@@ -76,6 +77,24 @@ public bool ShowEmptyRecycleBin
7677
}
7778
}
7879

80+
private bool _RecycleBinHasItems;
81+
82+
public bool RecycleBinHasItems
83+
{
84+
get
85+
{
86+
return _RecycleBinHasItems;
87+
}
88+
set
89+
{
90+
if (value != _RecycleBinHasItems)
91+
{
92+
_RecycleBinHasItems = value;
93+
NotifyPropertyChanged("RecycleBinHasItems");
94+
}
95+
}
96+
}
97+
7998
public event PropertyChangedEventHandler PropertyChanged;
8099

81100
private void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
@@ -142,7 +161,7 @@ private void Sidebar_ItemInvoked(Microsoft.UI.Xaml.Controls.NavigationView sende
142161
App.CurrentInstance.NavigationToolbar.PathControlDisplayText = App.CurrentInstance.FilesystemViewModel.WorkingDirectory;
143162
}
144163

145-
private void NavigationViewLocationItem_RightTapped(object sender, RightTappedRoutedEventArgs e)
164+
private async void NavigationViewLocationItem_RightTapped(object sender, RightTappedRoutedEventArgs e)
146165
{
147166
Microsoft.UI.Xaml.Controls.NavigationViewItem sidebarItem = (Microsoft.UI.Xaml.Controls.NavigationViewItem)sender;
148167
var item = sidebarItem.DataContext as LocationItem;
@@ -158,6 +177,21 @@ private void NavigationViewLocationItem_RightTapped(object sender, RightTappedRo
158177

159178
if (item.Path.Equals(App.AppSettings.RecycleBinPath, StringComparison.OrdinalIgnoreCase))
160179
{
180+
var value = new ValueSet
181+
{
182+
{ "Arguments", "RecycleBin" },
183+
{ "action", "Query" }
184+
};
185+
var response = await App.Connection.SendMessageAsync(value);
186+
if (response.Status == Windows.ApplicationModel.AppService.AppServiceResponseStatus.Success && response.Message.TryGetValue("NumItems", out var numItems))
187+
{
188+
RecycleBinHasItems = (long)numItems > 0;
189+
}
190+
else
191+
{
192+
RecycleBinHasItems = false;
193+
}
194+
161195
ShowEmptyRecycleBin = true;
162196
ShowUnpinItem = true;
163197
}

0 commit comments

Comments
 (0)