Implementing Calendar DateRange Picker
The WinUI CalendarDateRangePicker (SfCalendarDateRangePicker) control provides an intuitive, touch-friendly interface to quickly select a date range from a drop-down calendar. It supports different date formats, date range restrictions, preset items, week numbers, localization, and extensive UI customization options.
When to Use This Skill
Use this skill when you need to:
- Implement date range selection - Allow users to select a continuous range of dates (start date and end date) from a calendar
- Add CalendarDateRangePicker to WinUI apps - Install, configure, and use the SfCalendarDateRangePicker control
- Configure range selection - Set selected range programmatically, handle range change events, validate range selection
- Restrict date selection - Apply min/max dates, blackout specific dates, limit range duration, block weekend dates
- Customize calendar UI - Change drop-down alignment, customize item templates, apply themes, modify appearance
- Support localization - Use different calendar types (Gregorian, Hebrew, Hijri, etc.), change languages, apply RTL
- Format date display - Customize how dates and ranges are displayed in the editor and calendar
- Show preset ranges - Display predefined date ranges (This Week, This Month, Last Month, This Year, Custom Range)
- Enable week numbers - Show week numbers in the calendar with customizable rules and formats
- Handle navigation - Control view navigation (month, year, decade, century), keyboard shortcuts
- Validate date ranges - Ensure selected ranges meet minimum/maximum duration requirements
Component Overview
The CalendarDateRangePicker control consists of:
- Editor - Text input displaying the selected date range
- Drop-down button - Opens the calendar drop-down
- Drop-down calendar - Interactive calendar for range selection with month/year/decade/century views
- Preset items panel - Optional list of predefined date ranges
- Submit buttons - Optional OK/Cancel buttons for range confirmation
- Week numbers column - Optional display of week numbers
- Header and description - Optional title and helper text
Key capabilities:
- Touch-friendly range selection
- Multiple calendar systems (Gregorian, Hebrew, Hijri, Korean, etc.)
- Customizable date formats
- Date range restrictions and validation
- Blackout dates support
- Preset date ranges
- Week number display
- Keyboard navigation
- Theme customization
Documentation and Navigation Guide
Getting Started
📄 Read: references/getting-started.md
Use when:
- Installing the CalendarDateRangePicker control for the first time
- Adding the control to XAML or C# code
- Setting the selected range programmatically or interactively
- Configuring header, description, and placeholder text
- Handling selection changed events (SelectedDateRangeChanged)
- Showing or hiding the drop-down button
- Configuring submit buttons (OK/Cancel)
- Understanding basic control structure and setup
UI Customization
📄 Read: references/ui-customization.md
Use when:
- Changing drop-down alignment (top, bottom, left, right, center)
- Customizing drop-down calendar size
- Creating custom calendar item templates
- Highlighting special dates with custom styling
- Applying theme keys for colors and fonts
- Customizing day, week, and header appearance
- Using AttachedFlyout and DropDownFlyout for advanced customization
- Styling the CalendarItem control
- Creating event-based date decorations
Localization and Formatting
📄 Read: references/localization-formatting.md
Use when:
- Using different calendar types (Hebrew, Hijri, Korean, Thai, Persian, etc.)
- Changing the display language (Arabic, French, Japanese, etc.)
- Customizing editor display format (DisplayDateFormat)
- Formatting calendar days, months, and headers
- Changing the first day of the week
- Implementing right-to-left (RTL) flow direction
- Applying locale-specific date formatting
- Supporting international date conventions
Navigation Between Views
📄 Read: references/navigation.md
Use when:
- Enabling navigation between month, year, decade, and century views
- Restricting navigation with MinDisplayMode and MaxDisplayMode
- Implementing view-based selection (e.g., month/year for credit cards)
- Understanding keyboard navigation shortcuts
- Controlling which views users can access
- Navigating to specific dates or view levels
- Handling view switching in code
Restricting Date Range Selection
📄 Read: references/date-restrictions.md
Use when:
- Setting minimum and maximum selectable dates (MinDate, MaxDate)
- Blocking specific dates using BlackoutDates collection
- Disabling weekend dates or holidays dynamically
- Using ItemPrepared event for custom date restrictions
- Limiting range duration (MinDatesCountInRange, MaxDatesCountInRange)
- Validating selected date ranges
- Preventing invalid date range selection
- Customizing display text for blocked dates
Preset Items
📄 Read: references/preset-items.md
Use when:
- Showing predefined date ranges (This Week, This Month, Last Month, This Year)
- Creating custom preset items collection
- Implementing PresetTemplate for custom preset UI
- Handling preset selection events
- Hiding calendar when preset is selected (ShowCalendar)
- Calculating date ranges for preset items
- Allowing custom range selection alongside presets
Week Numbers
📄 Read: references/week-numbers.md
Use when:
- Enabling week number display (ShowWeekNumbers)
- Configuring week number rules (FirstDay, FirstFourDayWeek, FirstFullWeek)
- Customizing week number format with prefix/suffix
- Using WeekNumberTemplate for custom week number appearance
- Customizing WeekNameTemplate for day-of-week headers
- Understanding CalendarWeekRule options
- Applying week-based business logic
Quick Start
Basic Implementation
XAML:
<Window xmlns:calendar="using:Syncfusion.UI.Xaml.Calendar">
<Grid>
<calendar:SfCalendarDateRangePicker
x:Name="sfCalendarDateRangePicker"
HorizontalAlignment="Center"
VerticalAlignment="Center"
PlaceholderText="Select a date range" />
</Grid>
</Window>
C#:
using Syncfusion.UI.Xaml.Calendar;
SfCalendarDateRangePicker sfCalendarDateRangePicker = new SfCalendarDateRangePicker();
sfCalendarDateRangePicker.PlaceholderText = "Select a date range";
this.Content = sfCalendarDateRangePicker;
Setting Selected Range Programmatically
// Set a date range
sfCalendarDateRangePicker.SelectedRange = new DateTimeOffsetRange(
new DateTimeOffset(new DateTime(2026, 3, 1)),
new DateTimeOffset(new DateTime(2026, 3, 15))
);
// Clear selection
sfCalendarDateRangePicker.SelectedRange = null;
Handling Selection Changes
sfCalendarDateRangePicker.SelectedDateRangeChanged += (sender, e) =>
{
var startOld = e.RangeStartOldValue;
var startNew = e.RangeStartNewValue;
var endOld = e.RangeEndOldValue;
var endNew = e.RangeEndNewValue;
// Process the new range
if (startNew.HasValue && endNew.HasValue)
{
TimeSpan duration = endNew.Value - startNew.Value;
Debug.WriteLine($"Selected range: {duration.Days} days");
}
};
Common Patterns
Pattern 1: Date Range with Restrictions
// Restrict to future dates within 90 days
sfCalendarDateRangePicker.MinDate = DateTimeOffset.Now;
sfCalendarDateRangePicker.MaxDate = DateTimeOffset.Now.AddDays(90);
sfCalendarDateRangePicker.MinDatesCountInRange = 3; // Minimum 3 days
sfCalendarDateRangePicker.MaxDatesCountInRange = 14; // Maximum 14 days
Pattern 2: Blocking Weekend Dates
sfCalendarDateRangePicker.ItemPrepared += (sender, e) =>
{
if (e.ItemInfo.ItemType == CalendarItemType.Day &&
(e.ItemInfo.Date.DayOfWeek == DayOfWeek.Saturday ||
e.ItemInfo.Date.DayOfWeek == DayOfWeek.Sunday))
{
e.ItemInfo.IsBlackout = true;
}
};
Pattern 3: With Header and Description
<calendar:SfCalendarDateRangePicker
Header="Travel Dates"
Description="Select your departure and return dates"
PlaceholderText="Choose dates"
Width="300" />
Pattern 4: Custom Display Format
// Display as full date names
sfCalendarDateRangePicker.DisplayDateFormat = "{0:D} - {1:D}";
// Example: "Saturday, March 1, 2026 - Sunday, March 15, 2026"
Pattern 5: Localized Calendar
// Hebrew calendar with RTL support
sfCalendarDateRangePicker.CalendarIdentifier = "HebrewCalendar";
sfCalendarDateRangePicker.Language = "he-IL";
sfCalendarDateRangePicker.FlowDirection = FlowDirection.RightToLeft;
Key Properties
Selection Properties
- SelectedRange - Gets or sets the selected date range (DateTimeOffsetRange)
- MinDatesCountInRange - Minimum number of dates in the selected range
- MaxDatesCountInRange - Maximum number of dates in the selected range
Restriction Properties
- MinDate - Minimum selectable date (default: 1/1/1920)
- MaxDate - Maximum selectable date (default: 12/31/2120)
- BlackoutDates - Collection of dates to disable
Display Properties
- DisplayDateFormat - Format for displaying the selected range in the editor (default: "{0:d}-{1:d}")
- PlaceholderText - Watermark text when no range is selected
- Header - Title above the control
- HeaderTemplate - Custom template for the header
- Description - Helper text below the control
Calendar Properties
- CalendarIdentifier - Calendar system (Gregorian, Hebrew, Hijri, etc.)
- FirstDayOfWeek - Starting day of the week
- ShowWeekNumbers - Display week numbers
- WeekNumberRule - Rule for determining first week (FirstDay, FirstFourDayWeek, FirstFullWeek)
- WeekNumberFormat - Format for week numbers (default: "#")
Format Properties
- DayFormat - Format for day numbers in calendar
- MonthFormat - Format for month names in year view
- MonthHeaderFormat - Format for month/year header
- DayOfWeekFormat - Format for day-of-week names
Navigation Properties
- MinDisplayMode - Minimum view level (Month, Year, Decade, Century)
- MaxDisplayMode - Maximum view level (Month, Year, Decade, Century)
Drop-down Properties
- ShowDropDownButton - Show or hide the drop-down button
- ShowSubmitButtons - Show or hide OK/Cancel buttons
- ShowCalendar - Show or hide the calendar in drop-down
- DropDownPlacement - Alignment of drop-down (Bottom, Top, Left, Right, Center)
- DropDownHeight - Height of the drop-down calendar
Preset Properties
- Preset - Collection of preset date ranges
- PresetTemplate - Template for displaying preset items
- PresetPosition - Position of preset items (Left, Right, Top, Bottom)
Common Use Cases
- Booking Systems - Hotel reservations, flight bookings, rental services
- Reporting Tools - Select date ranges for reports and analytics
- Project Management - Define project start and end dates, sprint planning
- Calendar Applications - Event scheduling, meeting planning
- Financial Applications - Select statement periods, transaction date ranges
- HR Systems - Leave management, vacation planning, time tracking
- E-commerce - Delivery date selection, promotional period setup
- Healthcare - Appointment scheduling, treatment duration planning
Related Skills
1---2name: syncfusion-winui-calendar-date-range-picker3description: Implements Syncfusion WinUI CalendarDateRangePicker (SfCalendarDateRangePicker) control for selecting date ranges in desktop applications. Use this when building date range pickers, range selection calendars, or start/end date input interfaces. This skill covers range selection, preset ranges, blackout dates, date restrictions, week numbers, localization, and calendar customization for WinUI applications.4---56# Implementing Calendar DateRange Picker78The WinUI CalendarDateRangePicker (SfCalendarDateRangePicker) control provides an intuitive, touch-friendly interface to quickly select a date range from a drop-down calendar. It supports different date formats, date range restrictions, preset items, week numbers, localization, and extensive UI customization options.910## When to Use This Skill1112Use this skill when you need to:1314- **Implement date range selection** - Allow users to select a continuous range of dates (start date and end date) from a calendar15- **Add CalendarDateRangePicker to WinUI apps** - Install, configure, and use the SfCalendarDateRangePicker control16- **Configure range selection** - Set selected range programmatically, handle range change events, validate range selection17- **Restrict date selection** - Apply min/max dates, blackout specific dates, limit range duration, block weekend dates18- **Customize calendar UI** - Change drop-down alignment, customize item templates, apply themes, modify appearance19- **Support localization** - Use different calendar types (Gregorian, Hebrew, Hijri, etc.), change languages, apply RTL20- **Format date display** - Customize how dates and ranges are displayed in the editor and calendar21- **Show preset ranges** - Display predefined date ranges (This Week, This Month, Last Month, This Year, Custom Range)22- **Enable week numbers** - Show week numbers in the calendar with customizable rules and formats23- **Handle navigation** - Control view navigation (month, year, decade, century), keyboard shortcuts24- **Validate date ranges** - Ensure selected ranges meet minimum/maximum duration requirements2526## Component Overview2728The CalendarDateRangePicker control consists of:2930- **Editor** - Text input displaying the selected date range31- **Drop-down button** - Opens the calendar drop-down32- **Drop-down calendar** - Interactive calendar for range selection with month/year/decade/century views33- **Preset items panel** - Optional list of predefined date ranges34- **Submit buttons** - Optional OK/Cancel buttons for range confirmation35- **Week numbers column** - Optional display of week numbers36- **Header and description** - Optional title and helper text3738**Key capabilities:**39- Touch-friendly range selection40- Multiple calendar systems (Gregorian, Hebrew, Hijri, Korean, etc.)41- Customizable date formats42- Date range restrictions and validation43- Blackout dates support44- Preset date ranges45- Week number display46- Keyboard navigation47- Theme customization4849## Documentation and Navigation Guide5051### Getting Started52📄 **Read:** [references/getting-started.md](references/getting-started.md)5354**Use when:**55- Installing the CalendarDateRangePicker control for the first time56- Adding the control to XAML or C# code57- Setting the selected range programmatically or interactively58- Configuring header, description, and placeholder text59- Handling selection changed events (SelectedDateRangeChanged)60- Showing or hiding the drop-down button61- Configuring submit buttons (OK/Cancel)62- Understanding basic control structure and setup6364### UI Customization65📄 **Read:** [references/ui-customization.md](references/ui-customization.md)6667**Use when:**68- Changing drop-down alignment (top, bottom, left, right, center)69- Customizing drop-down calendar size70- Creating custom calendar item templates71- Highlighting special dates with custom styling72- Applying theme keys for colors and fonts73- Customizing day, week, and header appearance74- Using AttachedFlyout and DropDownFlyout for advanced customization75- Styling the CalendarItem control76- Creating event-based date decorations7778### Localization and Formatting79📄 **Read:** [references/localization-formatting.md](references/localization-formatting.md)8081**Use when:**82- Using different calendar types (Hebrew, Hijri, Korean, Thai, Persian, etc.)83- Changing the display language (Arabic, French, Japanese, etc.)84- Customizing editor display format (DisplayDateFormat)85- Formatting calendar days, months, and headers86- Changing the first day of the week87- Implementing right-to-left (RTL) flow direction88- Applying locale-specific date formatting89- Supporting international date conventions9091### Navigation Between Views92📄 **Read:** [references/navigation.md](references/navigation.md)9394**Use when:**95- Enabling navigation between month, year, decade, and century views96- Restricting navigation with MinDisplayMode and MaxDisplayMode97- Implementing view-based selection (e.g., month/year for credit cards)98- Understanding keyboard navigation shortcuts99- Controlling which views users can access100- Navigating to specific dates or view levels101- Handling view switching in code102103### Restricting Date Range Selection104📄 **Read:** [references/date-restrictions.md](references/date-restrictions.md)105106**Use when:**107- Setting minimum and maximum selectable dates (MinDate, MaxDate)108- Blocking specific dates using BlackoutDates collection109- Disabling weekend dates or holidays dynamically110- Using ItemPrepared event for custom date restrictions111- Limiting range duration (MinDatesCountInRange, MaxDatesCountInRange)112- Validating selected date ranges113- Preventing invalid date range selection114- Customizing display text for blocked dates115116### Preset Items117📄 **Read:** [references/preset-items.md](references/preset-items.md)118119**Use when:**120- Showing predefined date ranges (This Week, This Month, Last Month, This Year)121- Creating custom preset items collection122- Implementing PresetTemplate for custom preset UI123- Handling preset selection events124- Hiding calendar when preset is selected (ShowCalendar)125- Calculating date ranges for preset items126- Allowing custom range selection alongside presets127128### Week Numbers129📄 **Read:** [references/week-numbers.md](references/week-numbers.md)130131**Use when:**132- Enabling week number display (ShowWeekNumbers)133- Configuring week number rules (FirstDay, FirstFourDayWeek, FirstFullWeek)134- Customizing week number format with prefix/suffix135- Using WeekNumberTemplate for custom week number appearance136- Customizing WeekNameTemplate for day-of-week headers137- Understanding CalendarWeekRule options138- Applying week-based business logic139140## Quick Start141142### Basic Implementation143144**XAML:**145```xaml146<Window xmlns:calendar="using:Syncfusion.UI.Xaml.Calendar">147 <Grid>148 <calendar:SfCalendarDateRangePicker 149 x:Name="sfCalendarDateRangePicker"150 HorizontalAlignment="Center"151 VerticalAlignment="Center"152 PlaceholderText="Select a date range" />153 </Grid>154</Window>155```156157**C#:**158```csharp159using Syncfusion.UI.Xaml.Calendar;160161SfCalendarDateRangePicker sfCalendarDateRangePicker = new SfCalendarDateRangePicker();162sfCalendarDateRangePicker.PlaceholderText = "Select a date range";163this.Content = sfCalendarDateRangePicker;164```165166### Setting Selected Range Programmatically167168```csharp169// Set a date range170sfCalendarDateRangePicker.SelectedRange = new DateTimeOffsetRange(171 new DateTimeOffset(new DateTime(2026, 3, 1)), 172 new DateTimeOffset(new DateTime(2026, 3, 15))173);174175// Clear selection176sfCalendarDateRangePicker.SelectedRange = null;177```178179### Handling Selection Changes180181```csharp182sfCalendarDateRangePicker.SelectedDateRangeChanged += (sender, e) =>183{184 var startOld = e.RangeStartOldValue;185 var startNew = e.RangeStartNewValue;186 var endOld = e.RangeEndOldValue;187 var endNew = e.RangeEndNewValue;188 189 // Process the new range190 if (startNew.HasValue && endNew.HasValue)191 {192 TimeSpan duration = endNew.Value - startNew.Value;193 Debug.WriteLine($"Selected range: {duration.Days} days");194 }195};196```197198## Common Patterns199200### Pattern 1: Date Range with Restrictions201202```csharp203// Restrict to future dates within 90 days204sfCalendarDateRangePicker.MinDate = DateTimeOffset.Now;205sfCalendarDateRangePicker.MaxDate = DateTimeOffset.Now.AddDays(90);206sfCalendarDateRangePicker.MinDatesCountInRange = 3; // Minimum 3 days207sfCalendarDateRangePicker.MaxDatesCountInRange = 14; // Maximum 14 days208```209210### Pattern 2: Blocking Weekend Dates211212```csharp213sfCalendarDateRangePicker.ItemPrepared += (sender, e) =>214{215 if (e.ItemInfo.ItemType == CalendarItemType.Day &&216 (e.ItemInfo.Date.DayOfWeek == DayOfWeek.Saturday ||217 e.ItemInfo.Date.DayOfWeek == DayOfWeek.Sunday))218 {219 e.ItemInfo.IsBlackout = true;220 }221};222```223224### Pattern 3: With Header and Description225226```xaml227<calendar:SfCalendarDateRangePicker 228 Header="Travel Dates"229 Description="Select your departure and return dates"230 PlaceholderText="Choose dates"231 Width="300" />232```233234### Pattern 4: Custom Display Format235236```csharp237// Display as full date names238sfCalendarDateRangePicker.DisplayDateFormat = "{0:D} - {1:D}";239// Example: "Saturday, March 1, 2026 - Sunday, March 15, 2026"240```241242### Pattern 5: Localized Calendar243244```csharp245// Hebrew calendar with RTL support246sfCalendarDateRangePicker.CalendarIdentifier = "HebrewCalendar";247sfCalendarDateRangePicker.Language = "he-IL";248sfCalendarDateRangePicker.FlowDirection = FlowDirection.RightToLeft;249```250251## Key Properties252253### Selection Properties254- **SelectedRange** - Gets or sets the selected date range (DateTimeOffsetRange)255- **MinDatesCountInRange** - Minimum number of dates in the selected range256- **MaxDatesCountInRange** - Maximum number of dates in the selected range257258### Restriction Properties259- **MinDate** - Minimum selectable date (default: 1/1/1920)260- **MaxDate** - Maximum selectable date (default: 12/31/2120)261- **BlackoutDates** - Collection of dates to disable262263### Display Properties264- **DisplayDateFormat** - Format for displaying the selected range in the editor (default: "{0:d}-{1:d}")265- **PlaceholderText** - Watermark text when no range is selected266- **Header** - Title above the control267- **HeaderTemplate** - Custom template for the header268- **Description** - Helper text below the control269270### Calendar Properties271- **CalendarIdentifier** - Calendar system (Gregorian, Hebrew, Hijri, etc.)272- **FirstDayOfWeek** - Starting day of the week273- **ShowWeekNumbers** - Display week numbers274- **WeekNumberRule** - Rule for determining first week (FirstDay, FirstFourDayWeek, FirstFullWeek)275- **WeekNumberFormat** - Format for week numbers (default: "#")276277### Format Properties278- **DayFormat** - Format for day numbers in calendar279- **MonthFormat** - Format for month names in year view280- **MonthHeaderFormat** - Format for month/year header281- **DayOfWeekFormat** - Format for day-of-week names282283### Navigation Properties284- **MinDisplayMode** - Minimum view level (Month, Year, Decade, Century)285- **MaxDisplayMode** - Maximum view level (Month, Year, Decade, Century)286287### Drop-down Properties288- **ShowDropDownButton** - Show or hide the drop-down button289- **ShowSubmitButtons** - Show or hide OK/Cancel buttons290- **ShowCalendar** - Show or hide the calendar in drop-down291- **DropDownPlacement** - Alignment of drop-down (Bottom, Top, Left, Right, Center)292- **DropDownHeight** - Height of the drop-down calendar293294### Preset Properties295- **Preset** - Collection of preset date ranges296- **PresetTemplate** - Template for displaying preset items297- **PresetPosition** - Position of preset items (Left, Right, Top, Bottom)298299## Common Use Cases3003011. **Booking Systems** - Hotel reservations, flight bookings, rental services3022. **Reporting Tools** - Select date ranges for reports and analytics3033. **Project Management** - Define project start and end dates, sprint planning3044. **Calendar Applications** - Event scheduling, meeting planning3055. **Financial Applications** - Select statement periods, transaction date ranges3066. **HR Systems** - Leave management, vacation planning, time tracking3077. **E-commerce** - Delivery date selection, promotional period setup3088. **Healthcare** - Appointment scheduling, treatment duration planning309310## Related Skills311312- [Calendar](../syncfusion-winui-calendar/) - For single date selection313- [CalendarDatePicker](../syncfusion-winui-calendar-date-picker/) - For single date picker with drop-down