Advertisement
Guest User

Untitled

a guest
Aug 15th, 2016
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 KB | None | 0 0
  1.  public sealed partial class MainPage : Page
  2.     {
  3.         static StorageFolder currentFolder = KnownFolders.PicturesLibrary;
  4.  
  5.         public MainPage()
  6.         {
  7.             this.InitializeComponent();
  8.         }
  9.  
  10.         private async void ButtonBase_OnClick(object sender, RoutedEventArgs e)
  11.         {
  12.             await UpdateList();
  13.         }
  14.  
  15.         private static async Task<List<string>> GetSubFoldersNames()
  16.         {
  17.             if (currentFolder != null)
  18.             {
  19.                 var folderList = await currentFolder.GetFoldersAsync();
  20.  
  21.                 currentFolder = folderList.FirstOrDefault();
  22.  
  23.                 return folderList.Select(x => x.DisplayName).ToList();
  24.             }
  25.             else
  26.             {
  27.                 return new List<string>();
  28.             }
  29.         }
  30.  
  31.         private async Task UpdateList()
  32.         {
  33.             var list = await GetSubFoldersNames();
  34.             FoldersListView.ItemsSource = new ObservableCollection<string>(list);
  35.  
  36.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement