Back to Devexpress

How to: Conditionally Show and Hide Time Regions

wpf-401650-controls-and-libraries-scheduler-examples-how-to-conditionally-show-and-hide-time-regions.md

latest2.0 KB
Original Source

How to: Conditionally Show and Hide Time Regions

  • Feb 26, 2020

This example illustrates how to filter Time Regions that last less than a day in MonthView.

When you define a Time Region for an interval that is less than a day (several hours, minutes, etc.), the MonthView displays this region as if it takes the whole day. Handle the SchedulerControl.FilterTimeRegion event and set the event’s Visible property to false to hide time regions with a duration of less than 24 hours.

csharp
private void scheduler_FilterTimeRegion(object sender, FilterTimeRegionEventArgs e) {
    e.Visible = e.TimeRegion.Interval.Duration.TotalHours > 23
        || !(e.View is MonthView);
 }
vb
Private Sub scheduler_FilterTimeRegion(ByVal sender As Object, ByVal e As FilterTimeRegionEventArgs)
    e.Visible = e.TimeRegion.Interval.Duration.TotalHours > 23 OrElse Not (TypeOf e.View Is MonthView)
 End Sub

You can use DXEvent to define the SchedulerControl.FilterTimeRegion event in XAML.

View Example

xaml
<dxsch:SchedulerControl ...
       FilterTimeRegion="{DXEvent Handler='@args.Visible = @args.TimeRegion.Interval.Duration.TotalHours > 23 or !(@args.View is $dxsch:MonthView)'}">
    ...
</dxsch:SchedulerControl>