Articles in this section
Category / Section

How to change the time ruler size in WPF Scheduler (Calendar)?

3 mins read

You can change the time ruler view size by using the TimeRulerSize property of TimelineViewSettings in WPF Scheduler.

C#

Create class Meeting for appointment mapping.

public class Meeting
{
    public string EventName { get; set; }
    public DateTime From { get; set; }
    public DateTime To { get; set; }
    public Brush color { get; set; }
}

C#

Create a SchedulerViewModel class and map the appointments.

public class SchedulerViewModel : INotifyPropertyChanged
{
    private ObservableCollection<Meeting> meetings;
    public SchedulerViewModel()
    {
        this.Meetings = new ObservableCollection<Meeting>();
        this.AddAppointmentDetails();
        this.AddAppointments();
    }
    private void AddAppointmentDetails()
    {
        meetingSubjectCollection = new ObservableCollection<string>();
        meetingSubjectCollection.Add("BigDoor Board Meeting");
        meetingSubjectCollection.Add("Development Meeting");
        
 
        this.colorCollection = new ObservableCollection<Brush>();
        this.colorCollection.Add(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFA2C139")));
        this.colorCollection.Add(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFD80073")));
        this.colorCollection.Add(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF1BA1E2")));
    }
    private void AddAppointments()
    {
        var today = DateTime.Now;
        var random = new Random();
        for (int month = -1; month < 5; month++)
            {
                for (int day = -15; day < 15; day++)
                {
                    for (double hour = -12; hour < 12; hour++)
                    {
                        for (int count = 0; count < 1; count++)
                        {
                            var meeting = new Meeting();
                            meeting.EventName = meetingSubjectCollection[random.Next(6)];
                            meeting.color = colorCollection[random.Next(10)];
                            meeting.From = today.AddMonths(month).AddDays(day).AddHours(hour);
                            meeting.To = meeting.From.AddHours(1);
                            this.Meetings.Add(meeting);
                        }
                    }
                }
            }
      }
}

XAML

Bind the appointments to a schedule by using the Scheduler.ItemsSource property and set the TimeRulerSize as 100 in TimelineViewSettings to customize the size of the time ruler view

<Window.DataContext>
    <local:SchedulerViewModel/>
</Window.DataContext>
    <Grid>
        <syncfusion:SfScheduler 
        x:Name="Schedule" 
        ViewType="Timeline"
        ItemsSource="{Binding Meetings}">
            <syncfusion:SfScheduler.AppointmentMapping>
                <syncfusion:AppointmentMapping
                StartTime="From"
                EndTime="To"
                AppointmentBackground="color"
                Subject="EventName">
                </syncfusion:AppointmentMapping>
            </syncfusion:SfScheduler.AppointmentMapping>
            <syncfusion:SfScheduler.TimelineViewSettings>
                <syncfusion:TimelineViewSettings
                TimeRulerSize="100">
                </syncfusion:TimelineViewSettings>
            </syncfusion:SfScheduler.TimelineViewSettings>
        </syncfusion:SfScheduler>
    </Grid>

View sample in GitHub

Demo image for timeruler size


Conclusion

I hope you enjoyed learning about how to change the time ruler size in WPF Scheduler.

You can refer to our WPF Scheduler feature tour page to know about its other groundbreaking feature representations and documentationto understand how to create and manipulate data.

For current customers, you can check out our 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 other controls.

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)
Please  to leave a comment
Access denied
Access denied