We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Getting the name of the image from SfCrousel

Thread ID:

Created:

Updated:

Platform:

Replies:

145802 Jul 9,2019 08:02 AM UTC Aug 1,2019 08:54 AM UTC Xamarin.Forms 3
loading
Tags: SfCarousel
Julie Misson
Asked On July 9, 2019 08:02 AM UTC

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;


Muneesh Kumar G [Syncfusion]
Replied On July 9, 2019 11:43 AM UTC

Hi Julie Misson, 
 
Greetings from Syncfusion.  
 
We have checked your requirement "Getting the name of the image from SfCarousel" from our side and prepared a sample for that based on the provided code. In this sample, we get a selected item image name by using carousel SelectedIndex property value. Please find the sample from the below link. 
 
 
If the provided sample is not suitable for your requirement means, please provide more detail about your requirement. It will help us to provide an appropriate solution on this. 
  
Regards,  
Muneesh Kumar G.  
 


Julie Misson
Replied On August 1, 2019 08:49 AM UTC

Thanks,  worked perfectly.

Muneesh Kumar G [Syncfusion]
Replied On August 1, 2019 08:54 AM UTC

Hi Julie Misson,  
 
Thanks for the update. 
  
We are glad to know that the given solution works. Please let us know if you need any further assistance. 
 
Thanks,   
Muneesh Kumar G.   
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon