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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to move to required time while switching from month view to day view?

Platform: Xamarin.Forms |
Control: SfSchedule

In SfSchedule You can move to required time while switching Schedule view by using MoveToTime support in CellTapped event which will be fired while tapping schedule cell.

 

XAML

  
     < syncfusion :SfSchedule
       x:Name="schedule" ScheduleView="MonthView" 
       HorizontalOptions="FillAndExpand"  
       VerticalOptions="FillAndExpand" >
      </syncfusion :SfSchedule>
 

 

In CellTappedEventHandler, set required ScheduleView to be switched. Set NavigateTo to schedule with required hour and date to be moved on tapping a date on month cell. Such that view moves to that particular date and time in day view. Time of the day can be positioned in center of the view while switching from month view to day view by setting current time to the date and subtracting the hours needed from the current time of the day.

 

C#

 
       schedule.CellTapped += CellTappedEventHandler; 
 
       void CellTappedEventHandler(object sender, CellTappedEventArgs e)
       { 
           if (schedule.ScheduleView == ScheduleView.MonthView)
           {
                schedule.ScheduleView = ScheduleView.DayView;
                DateTime currentDate = DateTime.Now;                DateTime SpecificDateTime = new DateTime(currentDate.Year, currentDate.Month, currentDate.Day, currentDate.Hour, currentDate.Minute, currentDate.Second);
                var numberOfSecondsPerHour = 3600;
                var requiredHours = 6; 
                schedule.NavigateTo(e.Datetime.AddSeconds((SpecificDateTime.Hour - requiredHours) * numberOfSecondsPerHour));
           } 
       } 
 

 

You can download the source code for entire demo of switching schedule view through event from here, ScheduleSample.

2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

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

Up arrow icon

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