// Factory method to create the datasource
 // Requires async work which is why it needs a factory rather than being part of the constructor
 public static async Task<FileDataSource> GetDataSoure(string path)
 {
     FileDataSource ds = new FileDataSource();
     StorageFolder f = await StorageFolder.GetFolderFromPathAsync(path);
     await ds.SetFolder(f);
     return ds;
 }
        // Factory method to create the datasource
        // Requires async work which is why it needs a factory rather than being part of the constructor
        public static async Task <FileDataSource> GetDataSoure(string path)
        {
            FileDataSource ds = new FileDataSource();
            StorageFolder  f  = await StorageFolder.GetFolderFromPathAsync(path);

            await ds.SetFolder(f);

            return(ds);
        }
Пример #3
0
        async void initdata()
        {
            StorageLibrary pictures = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Pictures);

            string path = pictures.SaveFolder.Path;

            FileDataSource ds = await FileDataSource.GetDataSoure(path);

            if (ds.Count > 0)
            {
                Grid1.ItemsSource = ds;
            }
            else
            {
                MainPage.Current.NotifyUser("Error: The pictures folder doesn't contain any files", NotifyType.ErrorMessage);
            }
        }