Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/syncfusionexamples/display-cameraimage-listview-xamarin

This repository contains sample about how to display images taken from the camera on the Xamarin.Forms ListView (SfListView)?
https://github.com/syncfusionexamples/display-cameraimage-listview-xamarin

camera image imagesource itemtemplate listview listview-image-access loading-captured-image media-plugin picture sflistview xamarin xamarin-forms

Last synced: 7 days ago
JSON representation

This repository contains sample about how to display images taken from the camera on the Xamarin.Forms ListView (SfListView)?

Awesome Lists containing this project

README

        

# How to display images taken from the camera on the Xamarin.Forms ListView (SfListView)?
You can display images taken by camera in [SfListView](https://help.syncfusion.com/xamarin/listview/overview) by loading Image in the [SfListView.ItemTemplate](https://help.syncfusion.com/cr/xamarin/Syncfusion.ListView.XForms.SfListView.html#Syncfusion_ListView_XForms_SfListView_ItemTemplate).

To know more about using Media plugin for Xamarin, you can refer from the following link: https://github.com/jamesmontemagno/MediaPlugin

Take a photo using CrossMedia plugin and convert to ImageSource.
``` C#
namespace SfListViewSample
{
public class ViewModel
{
private int count = 0;

public Command TakePhotoCommand { get; set; }

public ViewModel()
{
ContactsInfo = new ObservableCollection();
TakePhotoCommand = new Command(OnTakePhotoClicked);
}

private async void OnTakePhotoClicked(object obj)
{
count += 1;
var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
{
Directory = "Media\\Pictures",
Name = "Image" + count,
SaveToAlbum = false,
CompressionQuality = 75,
CustomPhotoSize = 50,
MaxWidthHeight = 2000,
});
var details = new ListViewContactsInfo()
{
ContactNumber = random.Next(100, 400).ToString() + "-" + random.Next(500, 800).ToString() + "-" + random.Next(1000, 2000).ToString(),
ContactName = CustomerNames[count],
};

if (file == null)
return;

details.ContactImage = ImageSource.FromStream(() =>
{
var stream = file.GetStream();
return stream;
});

ContactsInfo.Add(details);
}
}
}
```
Display the taken image using FFImageLoading in the ItemTemplate.
``` xml









...





```