Category / Section
How to switch between Schedule views in WPF (Calendar)
4 mins read
In SfScheduler, you can switch between schedule views by using CellTapped event which will be fired while tapping the schedule 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, set required scheduler ViewType to be switched. On tapping a date on month cell, view moves to that particular date in day view.
using Microsoft.Xaml.Behaviors; using Syncfusion.UI.Xaml.Scheduler; namespace WpfScheduler { public class SchedulerBehavior : Behavior<SfScheduler> { SfScheduler scheduler; protected override void OnAttached() { base.OnAttached(); scheduler = this.AssociatedObject; this.AssociatedObject.CellTapped += Schedule_CellTapped; } private void Schedule_CellTapped(object sender, CellTappedEventArgs e) { this.AssociatedObject.ViewType = SchedulerViewType.Day; } protected override void OnDetaching() { base.OnDetaching(); this.AssociatedObject.CellTapped += Schedule_CellTapped; this.scheduler = null; } } }
Output