Calendar
The Calendar control is a standard Calendar control for users to select date(s) or date ranges.

Common Properties

Property
Description
SelectionMode
Gets or sets a value that indicates what kind of selections are allowed.
DisplayMode
Gets or sets a value indicating whether the calendar is displayed in months, years, or decades.
SelectedDate
Gets or sets the currently selected date.
SelectedDates
Gets a collection of selected dates.
DisplayDate
Gets or sets the date to display.
DisplayDateStart
Gets or sets the first date to be displayed.
DisplayDateEnd
Gets or sets the last date to be displayed.
BlackoutDates
Gets a collection of dates that are marked as not selectable.

Reference

​Calendar​

Source code

​Calendar.cs​

Examples

Basic Calendar

1
<Window xmlns="https://github.com/avaloniaui"
2
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
4
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
6
x:Class="AvaloniaAppTemplate.MainWindow"
7
Title="AvaloniaAppTemplate">
8
<StackPanel>
9
<Calendar SelectionMode="SingleDate" />
10
</StackPanel>
11
</Window>
Copied!

Range selection Calendar

1
<Window xmlns="https://github.com/avaloniaui"
2
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
4
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
6
x:Class="AvaloniaAppTemplate.MainWindow"
7
Title="AvaloniaAppTemplate">
8
<StackPanel>
9
<Calendar SelectionMode="SingleRange" />
10
</StackPanel>
11
</Window>
Copied!
After selecting the start date, a single range can be selected by holding the shift key and clicking on the end date.

Calendar with custom start and end dates

1
<Window xmlns="https://github.com/avaloniaui"
2
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
4
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
6
x:Class="AvaloniaAppTemplate.MainWindow"
7
Title="AvaloniaAppTemplate">
8
<StackPanel>
9
<Calendar Name="DisplayDatesCalendar" SelectionMode="SingleDate"/>
10
</StackPanel>
11
</Window>
Copied!
With this code to set the start and end dates:
1
var today = DateTime.Today;
2
var cal1 = this.FindControl<Calendar>("DisplayDatesCalendar");
3
cal1.DisplayDateStart = today.AddDays(-25);
4
cal1.DisplayDateEnd = today.AddDays(25);
Copied!
Last modified 6mo ago