using FileManager_UWP.Model; using FileManager_UWP.Service; using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.Command; using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; using Windows.Storage; namespace FileManager_UWP.ViewModel { public class FileListViewModel : ViewModelBase { /// /// 当前路径 /// private string _path = "C:\\"; public string Path { get => _path; set => Set(nameof(Path), ref _path, value); } /// /// 文件和文件夹列表 /// private IEnumerable _displayFileFolderItems; public IEnumerable DisplayFileFolderItems { get => _displayFileFolderItems; set => Set(nameof(DisplayFileFolderItem), ref _displayFileFolderItems, value); } /// /// 刷新命令 /// public RelayCommand _refreshCommand; public RelayCommand RefreshCommand => _refreshCommand ?? (_refreshCommand = new RelayCommand(async () => { var todoItemService = new FileService(); var todoItemList = await todoItemService.GetDisplayFileFolderList(Path); DisplayFileFolderItems = todoItemList; foreach (var i in DisplayFileFolderItems) Debug.WriteLine(i.Name); Debug.WriteLine(Path + todoItemList.Count); })); } }