How to set time in Carousel View???

unknown123unknown123 Member ✭✭✭

I want to set the time in horizontally and also carousel the time to change, selected time should be in different color
like below image 👇

im already tried to carousel the time using a plugin called CarouselView.FormsPlugin but i want to change colour of the selected time??

How can i achieve this..???


  • chetanrawatchetanrawat USMember ✭✭✭

    Hi, @unknown123

    can you share your code

  • unknown123unknown123 Member ✭✭✭
    edited April 12

    This is my XAML CODE 👇

      <controls1:CarouselViewControl  ShowArrows="True" x:Name="xx" Position="10" IsSwipeEnabled="True"  InterPageSpacing="-310" HeightRequest="40" >
                                    <ContentView >
                                        <AbsoluteLayout HeightRequest="50" >
                                            <StackLayout Orientation="Vertical" AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="1, 1, 1, 1">
                                                <Label Text="{Binding datetime}" HorizontalTextAlignment="Center"  FontSize="15"/>
                                                <Label Text="{Binding timeFormat}" HorizontalTextAlignment="Center" FontSize="15"/>

    This is my CS 👇

    TimeSpan end = TimeSpan.Parse("12:00");
                TimeSpan start = TimeSpan.Parse("00:00");
                TimeSpan addCount = TimeSpan.Parse("00:30");
                List<timeList> time1 = new List<timeList>();
                string timeFormat1 = "AM";
                for (int j = 0; j < 2; j++)
                    for (TimeSpan i = start; i <= end; i = i + addCount)
                        time1.Add(new timeList { dateTime = i.ToString(@"hh\:mm"), timeFormat = timeFormat1 });
                    timeFormat1 = "PM";
                    end = TimeSpan.Parse("11:29");
                    start = TimeSpan.Parse("00:30");
                xxxx.ItemsSource = time1;
  • amirasemanamiraseman Member ✭✭

    Give your label a name. Then change the colour of the text.


    In CS call this when you need.

    My_Label.TextColor = Color.Azure;
  • amirasemanamiraseman Member ✭✭

    Also you need a gesture recogniser added to your labels or CarouselViewControl to detect selection.

  • VetriiVetrii Member ✭✭

    Hi @amiraseman
    x:name is not working in carousel view.

  • chetanrawatchetanrawat USMember ✭✭✭

    Hi, @unknown123
    Below code give you index or postion of CaroselView
    private void CaroselViewPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
    var item = sender as CarouselView.FormsPlugin.Abstractions.CarouselViewControl;
    if (item != null)
    slidePosition = item.Position;

    Create property of color and bind with TextColor and onbehalf of postion change value of color.

  • unknown123unknown123 Member ✭✭✭

    In above im created a static list view ,but now i want to create it with a dynamically.
    Based on the User selection date, time has to be change.
    example if user select a today's date i want to load a current time else to load a 12 hours format with a range difference of 30 mins.

    how to create it with a dynamic list

Sign In or Register to comment.