66using System . IO ;
77using System . Runtime . CompilerServices ;
88using Windows . ApplicationModel . DataTransfer ;
9+ using Windows . Foundation . Collections ;
910using Windows . UI . Xaml ;
1011using Windows . UI . Xaml . Controls ;
1112using 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