Exemple #1
0
 private void Files_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     if (e.NewItems != null)
     {
         foreach (var item in e.NewItems)
         {
             if (item is FileViewModel fvm)
             {
                 OpenDirectoryCommand.CanExecuteDependsOn(fvm, nameof(fvm.IsSelected));
                 DeleteCommand.CanExecuteDependsOn(fvm, nameof(fvm.IsSelected));
                 RenameCommand.CanExecuteDependsOn(fvm, nameof(fvm.IsSelected));
             }
         }
     }
     if (e.OldItems != null)
     {
         foreach (var item in e.OldItems)
         {
             if (item is FileViewModel fvm)
             {
                 OpenDirectoryCommand.RemoveCanExecuteDependency(fvm, nameof(fvm.IsSelected));
                 DeleteCommand.RemoveCanExecuteDependency(fvm, nameof(fvm.IsSelected));
                 RenameCommand.RemoveCanExecuteDependency(fvm, nameof(fvm.IsSelected));
             }
         }
     }
     OpenDirectoryCommand.RaiseCanExecuteChanged();
     DeleteCommand.RaiseCanExecuteChanged();
     RenameCommand.RaiseCanExecuteChanged();
 }