> For the complete documentation index, see [llms.txt](https://avaloniachina.gitbook.io/avalonia/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://avaloniachina.gitbook.io/avalonia/docs/controls/calendar.md).

# 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](http://reference.avaloniaui.net/api/Avalonia.Controls/Calendar/)

## Source code

[Calendar.cs](https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Controls/Calendar/Calendar.cs)

## Examples

### Basic Calendar

```markup
<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
        x:Class="AvaloniaAppTemplate.MainWindow"
        Title="AvaloniaAppTemplate">
	<StackPanel>
		<Calendar SelectionMode="SingleDate" />
	</StackPanel>
</Window>
```

### Range selection Calendar

```markup
<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
        x:Class="AvaloniaAppTemplate.MainWindow"
        Title="AvaloniaAppTemplate">
	<StackPanel>
		<Calendar SelectionMode="SingleRange" />
	</StackPanel>
</Window>
```

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

```markup
<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
        x:Class="AvaloniaAppTemplate.MainWindow"
        Title="AvaloniaAppTemplate">
	<StackPanel>
		<Calendar Name="DisplayDatesCalendar" SelectionMode="SingleDate"/>
	</StackPanel>
</Window>
```

With this code to set the start and end dates:

```csharp
var today = DateTime.Today; 
var cal1 = this.FindControl<Calendar>("DisplayDatesCalendar");
cal1.DisplayDateStart = today.AddDays(-25);
cal1.DisplayDateEnd = today.AddDays(25);
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://avaloniachina.gitbook.io/avalonia/docs/controls/calendar.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
