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(DisplayFileFolderItems), ref _displayFileFolderItems, value); } private string _debugText; public string DebugText { get => _debugText; set => Set(nameof(DebugText), ref _debugText, value); } /// /// 刷新命令 /// public RelayCommand _refreshCommand; public RelayCommand RefreshCommand => _refreshCommand ?? (_refreshCommand = new RelayCommand(async () => { var fileService = new FileService(); var fileList = await fileService.GetDisplayFileFolderList(Path); DebugText = fileList[0].Name; DisplayFileFolderItems = fileList; Debug.WriteLine(Path + fileList.Count); foreach (var i in DisplayFileFolderItems) { Debug.WriteLine(i.Name); } })); } }