ImageFromXamarinUI [](https://www.nuget.org/packages/ImageFromXamarinUI/) [](https://www.nuget.org/packages/ImageFromXamarinUI/) [](https://github.com/dimonovdd/ImageFromXamarinUI/blob/main/LICENSE) [](https://www.fuget.org/packages/ImageFromXamarinUI) [](https://youtu.be/O9D3NSYh1t0)

June 9, 2021 ยท View on GitHub

Extension methods for capturing images from UI

header

Available Platforms:

PlatformVersion
AndroidMonoAndroid90+
iOSXamarin.iOS10
.NET Standard2.0

Getting started

You can just watch the Video that @jfversluis published

This is how you can create a simple command to call CaptureImageAsync method

public ImageSource ResultImageSource { get; set; }

public ICommand CaptureCommand  => new Command<Xamarin.Forms.VisualElement>(OnCapture);

async void OnCapture(Xamarin.Forms.VisualElement element)
{
    try
    {
        var stream = await element.CaptureImageAsync(Color.White);
        ResultImageSource = ImageSource.FromStream(() => stream);
    }
    catch (Exception)
    {
        // Handle exception
    }        
}

You can pass in the calling element when the Command is triggered:

<StackLayout x:Name="rootView">
   <Button Text="Capture"
           Command="{Binding CaptureCommand}"
           CommandParameter="{x:Reference rootView}"/>
</StackLayout>