Vote count:
0
I have implemented FileOpenPicker (in behind code of xaml) in my application:
private async void OnFilesPicked(IReadOnlyList<StorageFile> files)
{
Image.Source = null;
if (files.Count > 0)
{
// Check if video or image and pick first file to show
var imageFile = files.FirstOrDefault(f => SupportedImageFileTypes.Contains(f.FileType.ToLower()));
if (imageFile != null)
{
var bitmapImage = new BitmapImage();
await bitmapImage.SetSourceAsync(await imageFile.OpenReadAsync());
Image.Source = bitmapImage;
}
}
}
private void BtnFileOpenPickerPhotosClick(object sender, RoutedEventArgs e)
{
TriggerPicker(SupportedImageFileTypes);
}
private static void TriggerPicker(IEnumerable<string> fileTypeFilers, bool shouldPickMultiple = false)
{
var fop = new FileOpenPicker();
foreach (var fileType in fileTypeFilers)
{
fop.FileTypeFilter.Add(fileType);
}
if (shouldPickMultiple)
{
fop.PickMultipleFilesAndContinue();
}
else
{
fop.PickSingleFileAndContinue();
}
}
The line Image.Source = bitmapImage (this is sending picture to xaml) does not work. I do not have any image in my xaml. How can I Bind this Bitmap to xaml? How I must do this correctly(construct xaml, construct viewmodel class and hook the fileopenpicker methods) step by step? I will be very grateful.
asked 22 secs ago
MVVM: Image Bind Source from FileOpenPicker
Aucun commentaire:
Enregistrer un commentaire