Articles in this section

How to move to the required time while switching from month to day view in WPF Scheduler (Calendar)?

In WPF Scheduler, you can move to the required time while switching the scheduler view by using DisplayDate property in CellTapped event which will be fired while tapping the scheduler cell.

XAML

Interaction behavior added to SfScheduler to handle the CellTapped handler. 

<syncfusion:SfScheduler 
    x:Name="Schedule" 
    ViewType="Month">
    <interactivity:Interaction.Behaviors>
        <local:SchedulerBehavior/>
    </interactivity:Interaction.Behaviors>
</syncfusion:SfScheduler>

C#

In CellTapped event, set required SchedulerViewType to be switched. Set DisplayDate 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.

public class SchedulerBehavior : Behavior<SfScheduler>
{
    SfScheduler scheduler;
    protected override void OnAttached()
    {
        base.OnAttached();
        scheduler = this.AssociatedObject;
        this.AssociatedObject.CellTapped += Scheduler_CellTapped;
    }
    private void Scheduler_CellTapped(object sender, CellTappedEventArgs e)
    {
        this.AssociatedObject.ViewType = SchedulerViewType.Day;
 
        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;
        this.AssociatedObject.DisplayDate = e.DateTime.AddSeconds((SpecificDateTime.Hour - requiredHours) * numberOfSecondsPerHour);
    }
    protected override void OnDetaching()
    {
        base.OnDetaching();
        this.AssociatedObject.CellTapped -= Scheduler_CellTapped;
        this.scheduler = null;
    }
}        

Output

Demo image to move to required time while switching from month view to day view in Wpf

View Sample in GitHub


Conclusion

Hope you enjoyed learning about How to move to the required time while switching from month to day view in WPF Scheduler (Calendar). You can refer to our WPF Scheduler feature tour page to learn about its other groundbreaking feature representations. You can explore our WPF Scheduler documentation to understand how to present and manipulate data.

For current customers, you can check out our Angular components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our Angular Diagram and other Angular components.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied