Click or drag to resize

Attachment Class

Represents a geodatabase attachment type.
Inheritance Hierarchy
SystemObject
  Esri.ArcGISRuntime.DataAttachment

Namespace:  Esri.ArcGISRuntime.Data
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 100.6.0.0
Syntax
C#
public sealed class Attachment

The Attachment type exposes the following members.

Properties
  NameDescription
Public propertyCode exampleContentType
Gets the content type of the attachment.
Public propertyHasFetchedData
Gets a value indicating whether data has been retrieved.
Public propertyId
Gets the id of the attachment.
Public propertyCode exampleName
Gets the name of the attachment.
Public propertySize
Gets the size of the attachment's data.
Top
Methods
  NameDescription
Public methodCode exampleGetDataAsync
Asynchronously retrieves attachment's data.
Top
Examples

Android

Example Name: EditFeatureAttachments

Add, delete, and download attachments for features from a service.

Code example screen shot.

C#
// Copyright 2019 Esri.
// 
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an 
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 
// language governing permissions and limitations under the License.

using Android.App;
using Android.OS;
using Android.Widget;
using Esri.ArcGISRuntime.Data;
using Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.UI.Controls;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Android.Content;
using Android.Graphics;
using Android.Views;

namespace ArcGISRuntimeXamarin.Samples.EditFeatureAttachments
{
    [Activity (ConfigurationChanges=Android.Content.PM.ConfigChanges.Orientation | Android.Content.PM.ConfigChanges.ScreenSize)]
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        "Edit feature attachments",
        "Data",
        "Add, delete, and download attachments for features from a service.",
        "")]
    public class EditFeatureAttachments : Activity
    {
        // Hold references to the UI controls.
        private MapView _myMapView;
        private ListView _attachmentsListView;
        private Button _addButton;

        // Hold a reference to the layer.
        private FeatureLayer _damageLayer;

        // Hold references to the currently selected feature & any attachments.
        private ArcGISFeature _selectedFeature;
        private IReadOnlyList<Attachment> _featureAttachments;

        // URL to the feature service.
        private const string FeatureServiceUrl = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/DamageAssessment/FeatureServer/0";

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            Title = "Edit feature attachments";

            CreateLayout();
            Initialize();
        }

        private void Initialize()
        {
            // Create the map with streets basemap.
            _myMapView.Map = new Map(Basemap.CreateStreets());

            // Create the feature table, referring to the Damage Assessment feature service.
            ServiceFeatureTable damageTable = new ServiceFeatureTable(new Uri(FeatureServiceUrl));

            // Create a feature layer to visualize the features in the table.
            _damageLayer = new FeatureLayer(damageTable);

            // Add the layer to the map.
            _myMapView.Map.OperationalLayers.Add(_damageLayer);

            // Listen for user taps on the map.
            _myMapView.GeoViewTapped += MapView_Tapped;

            // Zoom to the United States.
            _myMapView.SetViewpointCenterAsync(new MapPoint(-10800000, 4500000, SpatialReferences.WebMercator), 3e7);
        }

        private async void MapView_Tapped(object sender, GeoViewInputEventArgs e)
        {
            // Clear any existing selection.
            _damageLayer.ClearSelection();
            _addButton.Enabled = false;
            _attachmentsListView.Enabled = false;

            try
            {
                // Perform an identify to determine if a user tapped on a feature.
                IdentifyLayerResult identifyResult = await _myMapView.IdentifyLayerAsync(_damageLayer, e.Position, 2, false);

                // Do nothing if there are no results.
                if (!identifyResult.GeoElements.Any())
                {
                    return;
                }

                // Get the selected feature as an ArcGISFeature. It is assumed that all GeoElements in the result are of type ArcGISFeature.
                GeoElement tappedElement = identifyResult.GeoElements.First();
                _selectedFeature = (ArcGISFeature) tappedElement;

                // Update the UI.
                UpdateUIForFeature();
                _addButton.Enabled = true;
                _attachmentsListView.Enabled = true;
            }
            catch (Exception ex)
            {
                ShowMessage(ex.ToString(), "Error selecting feature");
            }
        }

        private async void UpdateUIForFeature()
        {
            // Select the feature.
            _damageLayer.SelectFeature(_selectedFeature);

            // Get the attachments.
            _featureAttachments = await _selectedFeature.GetAttachmentsAsync();

            // Limit to only feature attachments with an image/jpeg content type.
            _featureAttachments = _featureAttachments.Where(attachment => attachment.ContentType == "image/jpeg").ToList();

            // Configure array adapter.
            ArrayAdapter attachmentAdapter = new ArrayAdapter<string>(
                this,
                Android.Resource.Layout.SimpleListItem1,
                _featureAttachments.Select(attachment => attachment.Name).ToArray());

            // Populate the list.
            _attachmentsListView.Adapter = attachmentAdapter;
        }

        private async Task PreviewAttachment(Attachment selectedAttachment)
        {
            if (selectedAttachment.ContentType.Contains("image"))
            {
                // Get the image data.
                Stream contentStream = await selectedAttachment.GetDataAsync();
                byte[] attachmentData = new byte[contentStream.Length];
                contentStream.Read(attachmentData, 0, attachmentData.Length);

                // Convert the image into a usable form on Android.
                Bitmap bmp = BitmapFactory.DecodeByteArray (attachmentData, 0, attachmentData.Length);

                // Create the view that will present the image.
                ImageView imageView = new ImageView(this);
                imageView.SetImageBitmap(bmp);

                // Show the image view in a dialog.
                ShowImageDialog(imageView);
            }
            else
            {
                ShowMessage("This sample can only show image attachments", "Can't show attachment");
            }
        }

        private void ShowImageDialog(ImageView previewImageView)
        {
            // Create the dialog.
            Dialog imageDialog = new Dialog(this);

            // Remove the title bar for the dialog.
            imageDialog.Window.RequestFeature(WindowFeatures.NoTitle);

            // Add the image to the dialog.
            imageDialog.SetContentView(previewImageView);

            // Show the dialog.
            imageDialog.Show();
        }

        private async Task DeleteAttachment(Attachment attachmentToDelete)
        {
            try
            {
                // Delete the attachment.
                await _selectedFeature.DeleteAttachmentAsync(attachmentToDelete);

                // Get a reference to the feature's service feature table.
                ServiceFeatureTable serviceTable = (ServiceFeatureTable) _selectedFeature.FeatureTable;

                // Apply the edits to the service feature table.
                await serviceTable.ApplyEditsAsync();

                // Update UI.
                _selectedFeature.Refresh();
                _featureAttachments = await _selectedFeature.GetAttachmentsAsync();
                UpdateUIForFeature();
                ShowMessage("Successfully deleted attachment", "Success!");
            }
            catch (Exception exception)
            {
                ShowMessage(exception.ToString(), "Error deleting attachment");
            }
        }

        private void RequestImage()
        {
            // Start the process of requesting an image. Will be completed in OnActivityResult.
            Intent = new Intent();
            Intent.SetType("image/*.jpg");
            Intent.SetAction(Intent.ActionGetContent);
            StartActivityForResult(Intent.CreateChooser(Intent, "Select Picture"), 1000);
        }

        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            // Method called when the image picker activity ends.
            if (requestCode == 1000 && resultCode == Result.Ok && data != null)
            {
                // Get the path to the selected image.
                Android.Net.Uri uri = data.Data;

                // Upload the image as an attachment.
                AddAttachment(uri);
            }
            else
            {
                ShowMessage("No image selected.", "Error adding attachment");
            }
        }

        private async void AddAttachment(Android.Net.Uri imageUri)
        {
            string contentType = "image/jpeg";

            // Read the image into a stream.
            Stream stream = ContentResolver.OpenInputStream(imageUri);   

            // Read from the stream into the byte array.
            byte[] attachmentData;
            using (var memoryStream = new MemoryStream())
            {
                stream.CopyTo(memoryStream);
                attachmentData = memoryStream.ToArray();
            }

            // Add the attachment.
            // The contentType string is the MIME type for JPEG files, image/jpeg.
            await _selectedFeature.AddAttachmentAsync(imageUri.LastPathSegment + ".jpg", contentType, attachmentData);

            // Get a reference to the feature's service feature table.
            ServiceFeatureTable serviceTable = (ServiceFeatureTable) _selectedFeature.FeatureTable;

            // Apply the edits to the service feature table.
            await serviceTable.ApplyEditsAsync();

            // Update UI.
            _selectedFeature.Refresh();
            _featureAttachments = await _selectedFeature.GetAttachmentsAsync();
            UpdateUIForFeature();
            ShowMessage("Successfully added attachment", "Success!");
        }

        private void Attachment_Clicked(object sender, AdapterView.ItemClickEventArgs e)
        {
            // Get the selected attachment.
            Attachment selectedAttachment = _featureAttachments[e.Position];

            // Create menu to show options.
            PopupMenu menu = new PopupMenu(this, (ListView) sender);

            // Handle the click, calling the right method depending on the command.
            menu.MenuItemClick += async (o, menuArgs) =>
            {
                menu.Dismiss();
                switch (menuArgs.Item.ToString())
                {
                    case "View":
                        await PreviewAttachment(selectedAttachment);
                        break;
                    case "Delete":
                        await DeleteAttachment(selectedAttachment);
                        break;
                }
                UpdateUIForFeature();
            };

            // Add the menu commands.
            menu.Menu.Add("View");
            menu.Menu.Add("Delete");

            // Show menu in the view.
            menu.Show();
        }

        private void ShowMessage(string message, string title)
        {
            // Display the message to the user.
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.SetMessage(message).SetTitle(title).Show();
        }

        private void CreateLayout()
        {
            // Create a new vertical layout for the app.
            var layout = new LinearLayout(this) {Orientation = Orientation.Vertical};

            // Create the MapView.
            _myMapView = new MapView();

            // Create the help label.
            TextView helpLabel = new TextView(this);
            helpLabel.Text = "Tap to select features.";
            helpLabel.TextAlignment = TextAlignment.Center;
            helpLabel.Gravity = GravityFlags.Center;

            // Add the help label to the layout.
            layout.AddView(helpLabel);

            // Create and add a listview for showing attachments;
            _attachmentsListView = new ListView(this);
            _attachmentsListView.Enabled = false;
            _attachmentsListView.SetMinimumHeight(100);
            layout.AddView(_attachmentsListView);
            _attachmentsListView.ItemClick += Attachment_Clicked;

            // Create and add an 'add attachment' button.
            _addButton = new Button(this);
            _addButton.Text = "Add attachment";
            _addButton.Enabled = false;
            _addButton.Click += AddButton_Clicked;
            layout.AddView(_addButton);

            // Add the map view to the layout.
            layout.AddView(_myMapView);

            // Show the layout in the app.
            SetContentView(layout);
        }

        private void AddButton_Clicked(object sender, EventArgs e)
        {
            // Do nothing if nothing selected.
            if (_selectedFeature == null)
            {
                return;
            }

            // Start the process of requesting an image to add.
            RequestImage();
        }
    }
}
Examples

Xamarin Forms Android

Example Name: EditFeatureAttachments

Add, delete, and download attachments for features from a service.

Code example screen shot.

C#
// Copyright 2019 Esri.
// 
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an 
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 
// language governing permissions and limitations under the License.

using Esri.ArcGISRuntime.Data;
using Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Mapping;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Xamarin.Forms;
// Custom code is needed for presenting the image picker on iOS.
#if __IOS__
using Foundation;
using UIKit;
#else
using Plugin.FilePicker;
using Plugin.FilePicker.Abstractions;
#endif

namespace ArcGISRuntimeXamarin.Samples.EditFeatureAttachments
{
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        "Edit feature attachments",
        "Data",
        "Add, delete, and download attachments for features from a service.",
        "")]
    public partial class EditFeatureAttachments : ContentPage
    {
        // URL to the feature service.
        private const string FeatureServiceUrl = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/DamageAssessment/FeatureServer/0";

        // Hold a reference to the feature layer.
        private FeatureLayer _damageLayer;

        // Hold a reference to the recently selected feature.
        private ArcGISFeature _selectedFeature;

        public EditFeatureAttachments()
        {
            InitializeComponent();
            Initialize();
        }

        private void Initialize()
        {
            // Create the map with streets basemap.
            MyMapView.Map = new Map(Basemap.CreateStreets());

            // Create the feature table, referring to the Damage Assessment feature service.
            ServiceFeatureTable damageTable = new ServiceFeatureTable(new Uri(FeatureServiceUrl));

            // Create a feature layer to visualize the features in the table.
            _damageLayer = new FeatureLayer(damageTable);

            // Add the layer to the map.
            MyMapView.Map.OperationalLayers.Add(_damageLayer);

            // Listen for user taps on the map.
            MyMapView.GeoViewTapped += MapView_Tapped;

            // Zoom to the United States.
            MyMapView.SetViewpointCenterAsync(new MapPoint(-10800000, 4500000, SpatialReferences.WebMercator), 3e7);
        }

        private async void MapView_Tapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e)
        {
            // Clear any existing selection.
            _damageLayer.ClearSelection();
            _selectedFeature = null;

            // Reset the UI.
            AttachmentsListBox.IsEnabled = false;
            AttachmentsListBox.ItemsSource = null;
            AddAttachmentButton.IsEnabled = false;

            try
            {
                // Perform an identify to determine if a user tapped on a feature.
                IdentifyLayerResult identifyResult = await MyMapView.IdentifyLayerAsync(_damageLayer, e.Position, 2, false);

                // Do nothing if there are no results.
                if (!identifyResult.GeoElements.Any())
                {
                    return;
                }

                // Get the selected feature as an ArcGISFeature. It is assumed that all GeoElements in the result are of type ArcGISFeature.
                GeoElement tappedElement = identifyResult.GeoElements.First();
                ArcGISFeature tappedFeature = (ArcGISFeature) tappedElement;

                // Select the feature in the UI and hold a reference to the tapped feature in a field.
                _damageLayer.SelectFeature(tappedFeature);
                _selectedFeature = tappedFeature;

                // Load the feature.
                await tappedFeature.LoadAsync();

                // Get the attachments.
                IReadOnlyList<Attachment> attachments = await tappedFeature.GetAttachmentsAsync();

                // Populate the UI with a list of attachments that have a content type of image/jpeg.
                AttachmentsListBox.ItemsSource = attachments.Where(attachment => attachment.ContentType == "image/jpeg");
                AttachmentsListBox.IsEnabled = true;
                AddAttachmentButton.IsEnabled = true;
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Error selecting feature", ex.ToString(), "OK");
            }
        }

        private async void AddAttachment_Click(object sender, EventArgs e)
        {
            if (_selectedFeature == null)
            {
                return;
            }

            // Adjust the UI.
            AddAttachmentButton.IsEnabled = false;
            AttachmentActivityIndicator.IsVisible = true;

            // Get the file.
            string contentType = "image/jpeg";

            try
            {
                byte[] attachmentData;
                string filename;

                // Xamarin.Plugin.FilePicker shows the iCloud picker (not photo picker) on iOS.
                // This iOS code shows the photo picker.
#if __IOS__
                Stream imageStream = await GetImageStreamAsync();
                if (imageStream == null)
                {
                    return;
                }

                attachmentData = new byte[imageStream.Length];
                imageStream.Read(attachmentData, 0, attachmentData.Length);
                filename = _filename ?? "file1.jpeg";
#else
                // Show a file picker - this uses the Xamarin.Plugin.FilePicker NuGet package.
                FileData fileData = await CrossFilePicker.Current.PickFile(new[] {".jpg", ".jpeg"});
                if (fileData == null)
                {
                    return;
                }

                if (!fileData.FileName.EndsWith(".jpg") && !fileData.FileName.EndsWith(".jpeg"))
                {
                    await Application.Current.MainPage.DisplayAlert("Try again!", "This sample only allows uploading jpg files.", "OK");
                    return;
                }

                attachmentData = fileData.DataArray;
                filename = fileData.FileName;
#endif
                // Add the attachment.
                // The contentType string is the MIME type for JPEG files, image/jpeg.
                await _selectedFeature.AddAttachmentAsync(filename, contentType, attachmentData);

                // Get a reference to the feature's service feature table.
                ServiceFeatureTable serviceTable = (ServiceFeatureTable) _selectedFeature.FeatureTable;

                // Apply the edits to the service feature table.
                await serviceTable.ApplyEditsAsync();

                // Update UI.
                _selectedFeature.Refresh();
                AttachmentsListBox.ItemsSource = await _selectedFeature.GetAttachmentsAsync();

                await Application.Current.MainPage.DisplayAlert("Success!", "Successfully added attachment", "OK");
            }
            catch (Exception exception)
            {
                await Application.Current.MainPage.DisplayAlert("Error adding attachment", exception.ToString(), "OK");
            }
            finally
            {
                // Adjust the UI.
                AddAttachmentButton.IsEnabled = true;
                AttachmentActivityIndicator.IsVisible = false;
            }
        }

        private async void DeleteAttachment_Click(object sender, EventArgs e)
        {
            AttachmentActivityIndicator.IsVisible = true;

            try
            {
                // Get the attachment that should be deleted.
                Button sendingButton = (Button) sender;
                Attachment selectedAttachment = (Attachment) sendingButton.BindingContext;

                // Delete the attachment.
                await _selectedFeature.DeleteAttachmentAsync(selectedAttachment);

                // Get a reference to the feature's service feature table.
                ServiceFeatureTable serviceTable = (ServiceFeatureTable) _selectedFeature.FeatureTable;

                // Apply the edits to the service feature table.
                await serviceTable.ApplyEditsAsync();

                // Update UI.
                _selectedFeature.Refresh();
                AttachmentsListBox.ItemsSource = await _selectedFeature.GetAttachmentsAsync();

                // Show success message.
                await Application.Current.MainPage.DisplayAlert("Success!", "Successfully deleted attachment", "OK");
            }
            catch (Exception exception)
            {
                await Application.Current.MainPage.DisplayAlert("Error deleting attachment", exception.ToString(), "OK");
            }
            finally
            {
                AttachmentActivityIndicator.IsVisible = false;
            }
        }

        private async void DownloadAttachment_Click(object sender, EventArgs e)
        {
            try
            {
                // Get a reference to the button that raised the event.
                Button sendingButton = (Button) sender;

                // Get the attachment from the button's DataContext. The button's DataContext is set by the list view.
                Attachment selectedAttachment = (Attachment) sendingButton.BindingContext;

                if (selectedAttachment.ContentType.Contains("image"))
                {
                    // Create a preview and show it.
                    ContentPage previewPage = new ContentPage();
                    previewPage.Title = "Attachment preview";
                    Image imageView = new Image();
                    Stream contentStream = await selectedAttachment.GetDataAsync();
                    imageView.Source = ImageSource.FromStream(() => contentStream);
                    previewPage.Content = imageView;
                    await Navigation.PushAsync(previewPage);
                }
                else
                {
                    await Application.Current.MainPage.DisplayAlert("Can't show attachment", "This sample can only show image attachments.", "OK");
                }
            }
            catch (Exception exception)
            {
                await Application.Current.MainPage.DisplayAlert("Error reading attachment", exception.ToString(), "OK");
            }
        }

        // Image picker implementation.
        // Xamarin.Plugin.FilePicker shows an iCloud file picker; comment this out
        // and use the cross-platform implementation if that's what you want.
        // Note: code adapted from https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/dependency-service/photo-picker
#if __IOS__
        private TaskCompletionSource<Stream> _taskCompletionSource;
        private UIImagePickerController _imagePicker;
        private string _filename;

        private Task<Stream> GetImageStreamAsync()
        {
            // Create and define UIImagePickerController.
            _imagePicker = new UIImagePickerController
            {
                SourceType = UIImagePickerControllerSourceType.PhotoLibrary,
                MediaTypes = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.PhotoLibrary)
            };

            // Set event handlers.
            _imagePicker.FinishedPickingMedia += OnImagePickerFinishedPickingMedia;
            _imagePicker.Canceled += OnImagePickerCancelled;

            // Present UIImagePickerController.
            UIWindow window = UIApplication.SharedApplication.KeyWindow;
            var viewController = window.RootViewController;
            viewController.PresentModalViewController(_imagePicker, true);

            // Return Task object.
            _taskCompletionSource = new TaskCompletionSource<Stream>();
            return _taskCompletionSource.Task;
        }

        void OnImagePickerFinishedPickingMedia(object sender, UIImagePickerMediaPickedEventArgs args)
        {
            UIImage image = args.EditedImage ?? args.OriginalImage;
            _filename = args.ImageUrl.LastPathComponent;
            if (image != null)
            {
                // Convert UIImage to .NET Stream object.
                NSData data = image.AsJPEG(1);
                Stream stream = data.AsStream();

                UnregisterEventHandlers();

                // Set the Stream as the completion of the Task.
                _taskCompletionSource.SetResult(stream);
            }
            else
            {
                UnregisterEventHandlers();
                _taskCompletionSource.SetResult(null);
            }

            _imagePicker.DismissModalViewController(true);
        }

        void OnImagePickerCancelled(object sender, EventArgs args)
        {
            UnregisterEventHandlers();
            _taskCompletionSource.SetResult(null);
            _imagePicker.DismissModalViewController(true);
        }

        void UnregisterEventHandlers()
        {
            _imagePicker.FinishedPickingMedia -= OnImagePickerFinishedPickingMedia;
            _imagePicker.Canceled -= OnImagePickerCancelled;
        }
#endif
    }
}
XAML
<?xml version="1.0" encoding="utf-8"?>

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Xamarin.Forms;assembly=Esri.ArcGISRuntime.Xamarin.Forms"
             xmlns:resources="clr-namespace:Forms.Resources;assembly=ArcGISRuntime"
             x:Class="ArcGISRuntimeXamarin.Samples.EditFeatureAttachments.EditFeatureAttachments">
    <RelativeLayout>
        <esriUI:MapView x:Name="MyMapView" Style="{StaticResource MapWithFormStyle}"
                        BindingContext="{x:Reference Name=ResponsiveFormContainer}" />
        <resources:ResponsiveFormContainer x:Name="ResponsiveFormContainer">
            <Grid>
                <StackLayout Orientation="Vertical">
                    <Label Text="Tap features to select."
                           HorizontalTextAlignment="Center"
                           Margin="0,0,0,5"
                           FontAttributes="Bold" />
                    <ListView x:Name="AttachmentsListBox"
                              IsEnabled="False"
                              HeightRequest="100"
                              BackgroundColor="LightGray">
                        <!-- ItemTemplate defines how each item (Attachment) is rendered. -->
                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <ViewCell>
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="*" />
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="Auto" />
                                        </Grid.ColumnDefinitions>
                                        <Label Text="{Binding Name}"
                                               Margin="5,0,5,0"
                                               VerticalTextAlignment="Center" />
                                        <!-- DataTemplate sets the item as the button's DataContext automatically. -->
                                        <Button Text="🔎"
                                                Grid.Column="1"
                                                VerticalOptions="End"
                                                Margin="0,0,5,0"
                                                Clicked="DownloadAttachment_Click" />
                                        <!-- These symbols are emojis. Use Win+. on Windows to open the emoji picker. -->
                                        <Button Text="🗑"
                                                Grid.Column="2"
                                                VerticalOptions="End"
                                                Clicked="DeleteAttachment_Click" />
                                    </Grid>
                                </ViewCell>
                            </DataTemplate>
                        </ListView.ItemTemplate>
                    </ListView>
                    <Button x:Name="AddAttachmentButton"
                            Text="Add attachment"
                            IsEnabled="False"
                            Margin="0,5,0,5"
                            Clicked="AddAttachment_Click" />
                    <ActivityIndicator x:Name="AttachmentActivityIndicator"
                                       IsVisible="False"
                                       IsRunning="True" />
                </StackLayout>
            </Grid>
        </resources:ResponsiveFormContainer>
    </RelativeLayout>
</ContentPage>
See Also
Additional Examples
Hyperlink to ExampleDescription
EditFeatureAttachmentsAdd, delete, and download attachments for features from a service.