Not sure where you are having issues, for the listview aspect look at the bottom of this page. For email see the following and note the platform differences.
Xamarin Forms, How can i send the items from a ListView by email
Hi Xamarin Community,
I need help with something I am wondering around, how can I send pdf file using Xamarin forms, but in the file I need to bind the items in my listview like description, price, quantity,
Hope you can help me
Regards
4 answers
Sort by: Most helpful
-
-
Michael Mathias Hachen 81 Reputation points
2021-01-22T05:38:39.89+00:00 If you need to create a pdf you could use something like Syncfusion PDF Library. They have a community license.
-
JarvanZhang 23,951 Reputation points
2021-01-22T05:46:56.55+00:00 Hello,
Welcome to our Microsoft Q&A platform!
I am wondering around, how can I send pdf file using Xamarin forms, but in the file I need to bind the items in my listview like description, price, quantity
@Amasu For this function, try to use the Xamarin.Essentials.Email api to send the email and set the pdf file as the attachment. And you could detect the ItemSelected event of the listView to get the binding data of the item, then pass the data when sending the email.
Check the code:
public partial class Page1 : ContentPage { CustomModel model; ... private void Listview_ItemSelected(object sender, SelectedItemChangedEventArgs e) { model = e.SelectedItem as CustomModel; } void SendEmail() { var message = new EmailMessage { Subject = "Hello", Body = model.Content,//you could pass the content that get from the listview's item }; var file = xxx;// get the pdf file message.Attachments.Add(new EmailAttachment(file));//send the file as attachment await Email.ComposeAsync(message); } }
Best Regards,
Jarvan Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
-
Selva Ganapathy K 1 Reputation point
2021-01-30T07:03:28.663+00:00 Hi,
You can achieve your requirement with Syncfusion ListView, Please find the example here.
In the example:
- Loaded a simple SfListView with ten items.
- In a button click exported the list view items into a pdf file
- In the same button click after the pdf creation is complete it will open the default mail app with the newly created pdf file as an attachment.
- In UWP permissions has to be provided.
- In Android storage permission has to be enabled to the app in the app's settings.
Note: I work for Syncfusion