Welcome to the Xamarin.Forms feedback portal. We’re happy you’re here! If you have feedback on how to improve the Xamarin.Forms, we’d love to hear it!

  • Check out the features or bugs others have reported and vote on your favorites. Feedback will be prioritized based on popularity.
  • If you have feedback that’s not listed yet, submit your own.

Thanks for joining our community and helping improve Syncfusion products!

0
Votes

Hello,

I am using a SFCalendar control in one of my page to show the week view. It has two navigation buttons on the side which calls Forward and Backward methods of the control, which triggers OnMonthCellLoaded event.

When I call Forward or Backward method, the control displays the next or previous week Date respectively, but the OnMonthCellLoaded event args are completely showing the wrong date.

For ex: 

If my control is currently displaying a date between 2019/01/19 to 2019/01/25 (Weekview) then when I call control.Backward(), the control properly displays a previous week with date between 2019/01/12 to 2019/01/18, but when the OnMonthCellLoaded event is triggered (7 times) the args date value goes one more week behind and date value starts from 2019/01/05 to 2019/01/11 (But what control displays a proper date).


Similarly, If my control is displaying a date between 2019/01/19 to 2019/01/25 (Weekview) then when I call control.Forward(), the control properly displays a next week with date between 2019/01/26 to 2019/02/01, but when the OnMonthCellLoaded event is triggered (7 times) the args date value goes one more week forward and date value starts from 2019/02/02 to 2019/02/08 (But what control displays a proper date).



I noticed this issue recently after upgrading to 17.4.0.44 because of the new code I added. But looks like this issue has been there before. I downgraded the SFCalendar and tested till the version 
17.4.0.40.
 

Here is my code:


 
<calendar:SfCalendar x:Name="TimeCalendar" Grid.Row="0" ShowYearView="False" ToggleDaySelection="True"
                                 FirstDayofWeek="{Binding FirstDayofWeek}"
                                 NumberOfWeeksInView="1"
                                 AgendaViewHeight="0" ViewMode="MonthView"
                                 EnableSwiping="True" SelectionMode="SingleSelection"
                                 MonthChangedCommand="{Binding MonthViewChangedCommand}"
                                 SelectedDate="{Binding SelectedDate}"
                                 SelectionChangedCommand="{Binding SelectedDateChangedCommand}">
                <calendar:SfCalendar.Behaviors>
                    <behaviors:EventToCommandBehavior EventName="OnMonthCellLoaded"
                                                      Command="{Binding MonthCellLoadedCommand}"
                                                      EventArgsConverter="{StaticResource monthCellLoadedEventArgsConverter}" />
                </calendar:SfCalendar.Behaviors>
<calendar:SfCalendar.HeaderView>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="70" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="5*" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <ImageButton Grid.Column="0" Source="{StaticResource ic_navigate_before_white_24}" Margin="10"
                                     Aspect="Fill" Command="{Binding NavigateCalendarWeek}"
                                     CommandParameter="{StaticResource falseValue}" BackgroundColor="Gray" />
                        <Label Grid.Column="1" Text="{Binding CalendarHeaderDate}" TextColor="Black"
                               HorizontalTextAlignment="Center" VerticalTextAlignment="Center" FontAttributes="Bold"
                               FontSize="Large" />
                        <ImageButton Grid.Column="2" Margin="10" Source="{StaticResource ic_navigate_next_white_24}"
                                     Command="{Binding NavigateCalendarWeek}" BackgroundColor="Gray" Aspect="Fill"
                                     CommandParameter="{StaticResource trueValue}" />
                    </Grid>
                </calendar:SfCalendar.HeaderView>
......
private void CreateMonthCellView(object obj)
        {
            var e = (MonthCellLoadedEventArgs) obj;
            
            var labelTotal = new Label
            {
                
        Text = TimeEntryCollection.Where(x => x.DateBooked.Date == e.Date.Date).Sum(x => x.RegularHours).ToString()
            };             var labelDay = new Label             {                 Text = e.Date.Day.ToString(CultureInfo.InvariantCulture), FontAttributes =             }; ...........         }