private void ClearCommandAction(object parameter)
 {
     ErrorMessage = "";
     File         = null;
     CurrentFile  = null;
     Files.Clear();
     FilesExt.Clear();
 }
        private async void FileOpenCommandAction(object parameter)
        {
            ErrorMessage = "";
            var openPicker = new FileOpenPicker {
                ViewMode = PickerViewMode.Thumbnail
            };

            switch (FileType)
            {
            case FileType.Audio:
                openPicker.SuggestedStartLocation = PickerLocationId.MusicLibrary;
                foreach (string extension in _audioExtensions)
                {
                    openPicker.FileTypeFilter.Add(extension);
                }
                break;

            case FileType.Video:
                openPicker.SuggestedStartLocation = PickerLocationId.VideosLibrary;
                foreach (string extension in _videoExtensions)
                {
                    openPicker.FileTypeFilter.Add(extension);
                }
                break;

            case FileType.Picture:
                openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;

                foreach (string extension in _pictureExtensions)
                {
                    openPicker.FileTypeFilter.Add(extension);
                }

                break;

            default:
                openPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
                foreach (string extension in _allExtensions)
                {
                    openPicker.FileTypeFilter.Add(extension);
                }

                break;
            }

            if (SelectMultipleFiles)
            {
                IEnumerable <StorageFile> files = await openPicker.PickMultipleFilesAsync();

                if (await CheckSize(null, files))
                {
                    foreach (StorageFile file in files)
                    {
                        Files.Add(file);
                        FilesExt.Add(new FilePreview(file, RemoveCommand));
                    }
                    if (Files.Count > 0)
                    {
                        CurrentFile = FilesExt[FilesExt.Count - 1];
                    }
                }
                else
                {
                    ErrorMessage = ResourcesHelper.GetString("MmsLimit");
                }
            }
            else
            {
                StorageFile file = await openPicker.PickSingleFileAsync();

                if (file != null)
                {
                    if (await CheckSize(file, null))
                    {
                        Files.Clear();
                        FilesExt.Clear();
                        Files.Add(file);
                        FilesExt.Add(new FilePreview(file, RemoveCommand));
                        CurrentFile = FilesExt[FilesExt.Count - 1];
                        File        = file;
                    }
                    else
                    {
                        ErrorMessage = ResourcesHelper.GetString("MmsLimit");
                    }
                }
            }
        }