Hi,
I have a button on my page which when I click, I wish to share the current carousel image to Facebook. I have sorted out the share bit by using Xamarin essentials. I have tested this with just hardcoding the image name.
What I wish to know is how to get the image name from the Carousel. I have worked out how to get the index. I have tried various options, searched the forums here and searched the Internet, but cannot find the solution. I think I am missing the obvious. Any help would be appreciated.
async public void Handle_Clicked(object sender, EventArgs e)
{
var fn = MainCarouselView.SelectedIndex;
//await DisplayAlert("Index",fn.ToString(), "OK");
await Share.RequestAsync(new ShareFileRequest
{
Title = Title,
File = new ShareFile(fn.ToString())
});
}
The following is the list that the Carousel is based on. Note: I cannot use the list order as they are added in a random order to the grid by using a Guid.
public BirthCarousel()
{
InitializeComponent();
NavigationPage.SetHasNavigationBar(this, false);
List<string> imageName = new List<string>();
{
imageName.Add("birth01.jpg");
imageName.Add("birth02.jpg");
imageName.Add("birth03.jpg");
imageName.Add("birth04.jpg");
imageName.Add("birth05.jpg");
imageName.Add("birth06.jpg");
imageName.Add("birth07.jpg");
imageName.Add("birth08.jpg");
imageName.Add("birth09.jpg");
imageName.Add("birth10.jpg");
imageName.Add("birth11.jpg");
imageName.Add("birth12.jpg");
imageName.Add("birth13.jpg");
imageName.Add("birth14.jpg");
imageName.Add("birth15.png");
}
imageName = imageName.OrderBy(o => Guid.NewGuid().ToString()).ToList();
var idaysopened = Helpers.Settings.DaysOpened;
if (idaysopened > 12)
{
idaysopened = 13;
}
List<string> imageName1 = new List<string>();
{
imageName1.AddRange(imageName.Take(idaysopened + 3));
imageName1.Add("04forpages.png");
}
MainCarouselView.ItemsSource = imageName1;