Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

i wanted to show a page indicator below the carousel page in xamarin.forms

agassishajuagassishaju Member ✭✭
edited April 13 in Xamarin.Forms

Hi, i wanted to show a page indicator below the carousel page in xamarin.forms just like the image below. can someone help me with that. and also is there any way i could get that star characater into the labels or should i just add up the image.
Thanks

Answers

  • RainerMagerRainerMager JPMember ✭✭✭
    edited April 13

    Here's how I did a page indicator:

                <Label
                    Style="{DynamicResource LabelDots}"
                    Text="{Binding Dots}" />
    

    and in my view model:

            public string Dots
            {
                get {
                    if(CurrentItem is OfferViewModel offerViewModel) {
                        var dots = new List<string>();
                        foreach(var offer in Offers) {
                            dots.Add(offer == offerViewModel ? "●" : "○");
                        }
                        return string.Join(" ", dots);
                    }
                    return "●";
                }
            }
    

    Obviously you would need to change Offers in the foreach loop to your collection and make sure you have a binding to CurrentItem to compare against.

    If you want to make the dots different colors then this becomes a bit more complicated since you would need a separate label for each color.

  • agassishajuagassishaju Member ✭✭

    im sorry to say that im actually not that good in coding but i do get what you are trying to say, uh can you please tell me how to add binding to CurrentItem to compare against.

  • ColeXColeX Member, Xamarin Team Xamurai
    edited April 13

    Check the article : https://xamarinhelp.com/carousel-view-page-indicators/ .

    I created a simple sample here : https://forums.xamarin.com/discussion/comment/407796/#Comment_407796 , you can download and test it .


    is there any way i could get that star characater into the labels or should i just add up the image.

    Google rating control , you would find the answer.

Sign In or Register to comment.