diff --git a/src/Avalonia.Controls/Calendar/CalendarDatePicker.Properties.cs b/src/Avalonia.Controls/Calendar/CalendarDatePicker.Properties.cs
new file mode 100644
index 0000000000..e8fee4789b
--- /dev/null
+++ b/src/Avalonia.Controls/Calendar/CalendarDatePicker.Properties.cs
@@ -0,0 +1,306 @@
+using System;
+using Avalonia.Controls.Primitives;
+using Avalonia.Data;
+using Avalonia.Layout;
+
+namespace Avalonia.Controls
+{
+ ///
+ public partial class CalendarDatePicker
+ {
+ ///
+ /// Defines the property.
+ ///
+ public static readonly DirectProperty DisplayDateProperty =
+ AvaloniaProperty.RegisterDirect(
+ nameof(DisplayDate),
+ o => o.DisplayDate,
+ (o, v) => o.DisplayDate = v);
+
+ ///
+ /// Defines the property.
+ ///
+ public static readonly DirectProperty DisplayDateStartProperty =
+ AvaloniaProperty.RegisterDirect(
+ nameof(DisplayDateStart),
+ o => o.DisplayDateStart,
+ (o, v) => o.DisplayDateStart = v);
+
+ ///
+ /// Defines the property.
+ ///
+ public static readonly DirectProperty DisplayDateEndProperty =
+ AvaloniaProperty.RegisterDirect(
+ nameof(DisplayDateEnd),
+ o => o.DisplayDateEnd,
+ (o, v) => o.DisplayDateEnd = v);
+
+ ///
+ /// Defines the property.
+ ///
+ public static readonly StyledProperty FirstDayOfWeekProperty =
+ AvaloniaProperty.Register(nameof(FirstDayOfWeek));
+
+ ///
+ /// Defines the property.
+ ///
+ public static readonly DirectProperty IsDropDownOpenProperty =
+ AvaloniaProperty.RegisterDirect(
+ nameof(IsDropDownOpen),
+ o => o.IsDropDownOpen,
+ (o, v) => o.IsDropDownOpen = v);
+
+ ///
+ /// Defines the property.
+ ///
+ public static readonly StyledProperty IsTodayHighlightedProperty =
+ AvaloniaProperty.Register(nameof(IsTodayHighlighted));
+
+ ///
+ /// Defines the property.
+ ///
+ public static readonly DirectProperty SelectedDateProperty =
+ AvaloniaProperty.RegisterDirect(
+ nameof(SelectedDate),
+ o => o.SelectedDate,
+ (o, v) => o.SelectedDate = v,
+ enableDataValidation: true,
+ defaultBindingMode:BindingMode.TwoWay);
+
+ ///
+ /// Defines the property.
+ ///
+ public static readonly StyledProperty SelectedDateFormatProperty =
+ AvaloniaProperty.Register(
+ nameof(SelectedDateFormat),
+ defaultValue: CalendarDatePickerFormat.Short,
+ validate: IsValidSelectedDateFormat);
+
+ ///
+ /// Defines the property.
+ ///
+ public static readonly StyledProperty CustomDateFormatStringProperty =
+ AvaloniaProperty.Register(
+ nameof(CustomDateFormatString),
+ defaultValue: "d",
+ validate: IsValidDateFormatString);
+
+ ///
+ /// Defines the property.
+ ///
+ public static readonly DirectProperty TextProperty =
+ AvaloniaProperty.RegisterDirect(
+ nameof(Text),
+ o => o.Text,
+ (o, v) => o.Text = v);
+
+ ///
+ /// Defines the property.
+ ///
+ public static readonly StyledProperty WatermarkProperty =
+ TextBox.WatermarkProperty.AddOwner();
+
+ ///
+ /// Defines the property.
+ ///
+ public static readonly StyledProperty UseFloatingWatermarkProperty =
+ TextBox.UseFloatingWatermarkProperty.AddOwner();
+
+ ///
+ /// Defines the property.
+ ///
+ public static readonly StyledProperty HorizontalContentAlignmentProperty =
+ ContentControl.HorizontalContentAlignmentProperty.AddOwner();
+
+ ///
+ /// Defines the property.
+ ///
+ public static readonly StyledProperty VerticalContentAlignmentProperty =
+ ContentControl.VerticalContentAlignmentProperty.AddOwner();
+
+ ///
+ /// Gets a collection of dates that are marked as not selectable.
+ ///
+ ///
+ /// A collection of dates that cannot be selected. The default value is
+ /// an empty collection.
+ ///
+ public CalendarBlackoutDatesCollection? BlackoutDates { get; private set; }
+
+ ///
+ /// Gets or sets the date to display.
+ ///
+ ///
+ /// The date to display. The default
+ /// .
+ ///
+ ///
+ /// The specified date is not in the range defined by
+ ///
+ /// and
+ /// .
+ ///
+ public DateTime DisplayDate
+ {
+ get => _displayDate;
+ set => SetAndRaise(DisplayDateProperty, ref _displayDate, value);
+ }
+
+ ///
+ /// Gets or sets the first date to be displayed.
+ ///
+ /// The first date to display.
+ public DateTime? DisplayDateStart
+ {
+ get => _displayDateStart;
+ set => SetAndRaise(DisplayDateStartProperty, ref _displayDateStart, value);
+ }
+
+ ///
+ /// Gets or sets the last date to be displayed.
+ ///
+ /// The last date to display.
+ public DateTime? DisplayDateEnd
+ {
+ get => _displayDateEnd;
+ set => SetAndRaise(DisplayDateEndProperty, ref _displayDateEnd, value);
+ }
+
+ ///
+ /// Gets or sets the day that is considered the beginning of the week.
+ ///
+ ///
+ /// A representing the beginning of
+ /// the week. The default is .
+ ///
+ public DayOfWeek FirstDayOfWeek
+ {
+ get => GetValue(FirstDayOfWeekProperty);
+ set => SetValue(FirstDayOfWeekProperty, value);
+ }
+
+ ///
+ /// Gets or sets a value indicating whether the drop-down
+ /// is open or closed.
+ ///
+ ///
+ /// True if the is
+ /// open; otherwise, false. The default is false.
+ ///
+ public bool IsDropDownOpen
+ {
+ get => _isDropDownOpen;
+ set => SetAndRaise(IsDropDownOpenProperty, ref _isDropDownOpen, value);
+ }
+
+ ///
+ /// Gets or sets a value indicating whether the current date will be
+ /// highlighted.
+ ///
+ ///
+ /// True if the current date is highlighted; otherwise, false. The
+ /// default is true.
+ ///
+ public bool IsTodayHighlighted
+ {
+ get => GetValue(IsTodayHighlightedProperty);
+ set => SetValue(IsTodayHighlightedProperty, value);
+ }
+
+ ///
+ /// Gets or sets the currently selected date.
+ ///
+ ///
+ /// The date currently selected. The default is null.
+ ///
+ ///
+ /// The specified date is not in the range defined by
+ ///
+ /// and
+ /// ,
+ /// or the specified date is in the
+ ///
+ /// collection.
+ ///
+ public DateTime? SelectedDate
+ {
+ get => _selectedDate;
+ set => SetAndRaise(SelectedDateProperty, ref _selectedDate, value);
+ }
+
+ ///
+ /// Gets or sets the format that is used to display the selected date.
+ ///
+ ///
+ /// The format that is used to display the selected date. The default is
+ /// .
+ ///
+ ///
+ /// An specified format is not valid.
+ ///
+ public CalendarDatePickerFormat SelectedDateFormat
+ {
+ get => GetValue(SelectedDateFormatProperty);
+ set => SetValue(SelectedDateFormatProperty, value);
+ }
+
+ public string CustomDateFormatString
+ {
+ get => GetValue(CustomDateFormatStringProperty);
+ set => SetValue(CustomDateFormatStringProperty, value);
+ }
+
+ ///
+ /// Gets or sets the text that is displayed by the
+ /// .
+ ///
+ ///
+ /// The text displayed by the
+ /// .
+ ///
+ ///
+ /// The text entered cannot be parsed to a valid date, and the exception
+ /// is not suppressed.
+ ///
+ ///
+ /// The text entered parses to a date that is not selectable.
+ ///
+ public string? Text
+ {
+ get => _text;
+ set => SetAndRaise(TextProperty, ref _text, value);
+ }
+
+ ///
+ public string? Watermark
+ {
+ get => GetValue(WatermarkProperty);
+ set => SetValue(WatermarkProperty, value);
+ }
+
+ ///
+ public bool UseFloatingWatermark
+ {
+ get => GetValue(UseFloatingWatermarkProperty);
+ set => SetValue(UseFloatingWatermarkProperty, value);
+ }
+
+ ///
+ /// Gets or sets the horizontal alignment of the content within the control.
+ ///
+ public HorizontalAlignment HorizontalContentAlignment
+ {
+ get => GetValue(HorizontalContentAlignmentProperty);
+ set => SetValue(HorizontalContentAlignmentProperty, value);
+ }
+
+ ///
+ /// Gets or sets the vertical alignment of the content within the control.
+ ///
+ public VerticalAlignment VerticalContentAlignment
+ {
+ get => GetValue(VerticalContentAlignmentProperty);
+ set => SetValue(VerticalContentAlignmentProperty, value);
+ }
+ }
+}
diff --git a/src/Avalonia.Controls/Calendar/CalendarDatePicker.cs b/src/Avalonia.Controls/Calendar/CalendarDatePicker.cs
index 09330c2304..55ecd6b50c 100644
--- a/src/Avalonia.Controls/Calendar/CalendarDatePicker.cs
+++ b/src/Avalonia.Controls/Calendar/CalendarDatePicker.cs
@@ -121,7 +121,7 @@ namespace Avalonia.Controls
[TemplatePart(ElementCalendar, typeof(Calendar))]
[TemplatePart(ElementPopup, typeof(Popup))]
[TemplatePart(ElementTextBox, typeof(TextBox))]
- public class CalendarDatePicker : TemplatedControl
+ public partial class CalendarDatePicker : TemplatedControl
{
private const string ElementTextBox = "PART_TextBox";
private const string ElementButton = "PART_Button";
@@ -151,301 +151,6 @@ namespace Avalonia.Controls
private bool _isPopupClosing = false;
private bool _ignoreButtonClick = false;
- ///
- /// Gets a collection of dates that are marked as not selectable.
- ///
- ///
- /// A collection of dates that cannot be selected. The default value is
- /// an empty collection.
- ///
- public CalendarBlackoutDatesCollection? BlackoutDates { get; private set; }
-
- ///
- /// Defines the property.
- ///
- public static readonly DirectProperty DisplayDateProperty =
- AvaloniaProperty.RegisterDirect(
- nameof(DisplayDate),
- o => o.DisplayDate,
- (o, v) => o.DisplayDate = v);
-
- ///
- /// Defines the property.
- ///
- public static readonly DirectProperty DisplayDateStartProperty =
- AvaloniaProperty.RegisterDirect(
- nameof(DisplayDateStart),
- o => o.DisplayDateStart,
- (o, v) => o.DisplayDateStart = v);
-
- ///
- /// Defines the property.
- ///
- public static readonly DirectProperty DisplayDateEndProperty =
- AvaloniaProperty.RegisterDirect(
- nameof(DisplayDateEnd),
- o => o.DisplayDateEnd,
- (o, v) => o.DisplayDateEnd = v);
-
- ///
- /// Defines the property.
- ///
- public static readonly StyledProperty FirstDayOfWeekProperty =
- AvaloniaProperty.Register(nameof(FirstDayOfWeek));
-
- ///
- /// Defines the property.
- ///
- public static readonly DirectProperty IsDropDownOpenProperty =
- AvaloniaProperty.RegisterDirect(
- nameof(IsDropDownOpen),
- o => o.IsDropDownOpen,
- (o, v) => o.IsDropDownOpen = v);
-
- ///
- /// Defines the property.
- ///
- public static readonly StyledProperty IsTodayHighlightedProperty =
- AvaloniaProperty.Register(nameof(IsTodayHighlighted));
-
- ///
- /// Defines the property.
- ///
- public static readonly DirectProperty SelectedDateProperty =
- AvaloniaProperty.RegisterDirect(
- nameof(SelectedDate),
- o => o.SelectedDate,
- (o, v) => o.SelectedDate = v,
- enableDataValidation: true,
- defaultBindingMode:BindingMode.TwoWay);
-
- ///
- /// Defines the property.
- ///
- public static readonly StyledProperty SelectedDateFormatProperty =
- AvaloniaProperty.Register(
- nameof(SelectedDateFormat),
- defaultValue: CalendarDatePickerFormat.Short,
- validate: IsValidSelectedDateFormat);
-
- ///
- /// Defines the property.
- ///
- public static readonly StyledProperty CustomDateFormatStringProperty =
- AvaloniaProperty.Register(
- nameof(CustomDateFormatString),
- defaultValue: "d",
- validate: IsValidDateFormatString);
-
- ///
- /// Defines the property.
- ///
- public static readonly DirectProperty TextProperty =
- AvaloniaProperty.RegisterDirect(
- nameof(Text),
- o => o.Text,
- (o, v) => o.Text = v);
-
- ///
- /// Defines the property.
- ///
- public static readonly StyledProperty WatermarkProperty =
- TextBox.WatermarkProperty.AddOwner();
-
- ///
- /// Defines the property.
- ///
- public static readonly StyledProperty UseFloatingWatermarkProperty =
- TextBox.UseFloatingWatermarkProperty.AddOwner();
-
- ///
- /// Defines the property.
- ///
- public static readonly StyledProperty HorizontalContentAlignmentProperty =
- ContentControl.HorizontalContentAlignmentProperty.AddOwner();
-
- ///
- /// Defines the property.
- ///
- public static readonly StyledProperty VerticalContentAlignmentProperty =
- ContentControl.VerticalContentAlignmentProperty.AddOwner();
-
- ///
- /// Gets or sets the date to display.
- ///
- ///
- /// The date to display. The default
- /// .
- ///
- ///
- /// The specified date is not in the range defined by
- ///
- /// and
- /// .
- ///
- public DateTime DisplayDate
- {
- get => _displayDate;
- set => SetAndRaise(DisplayDateProperty, ref _displayDate, value);
- }
-
- ///
- /// Gets or sets the first date to be displayed.
- ///
- /// The first date to display.
- public DateTime? DisplayDateStart
- {
- get => _displayDateStart;
- set => SetAndRaise(DisplayDateStartProperty, ref _displayDateStart, value);
- }
-
- ///
- /// Gets or sets the last date to be displayed.
- ///
- /// The last date to display.
- public DateTime? DisplayDateEnd
- {
- get => _displayDateEnd;
- set => SetAndRaise(DisplayDateEndProperty, ref _displayDateEnd, value);
- }
-
- ///
- /// Gets or sets the day that is considered the beginning of the week.
- ///
- ///
- /// A representing the beginning of
- /// the week. The default is .
- ///
- public DayOfWeek FirstDayOfWeek
- {
- get => GetValue(FirstDayOfWeekProperty);
- set => SetValue(FirstDayOfWeekProperty, value);
- }
-
- ///
- /// Gets or sets a value indicating whether the drop-down
- /// is open or closed.
- ///
- ///
- /// True if the is
- /// open; otherwise, false. The default is false.
- ///
- public bool IsDropDownOpen
- {
- get => _isDropDownOpen;
- set => SetAndRaise(IsDropDownOpenProperty, ref _isDropDownOpen, value);
- }
-
- ///
- /// Gets or sets a value indicating whether the current date will be
- /// highlighted.
- ///
- ///
- /// True if the current date is highlighted; otherwise, false. The
- /// default is true.
- ///
- public bool IsTodayHighlighted
- {
- get => GetValue(IsTodayHighlightedProperty);
- set => SetValue(IsTodayHighlightedProperty, value);
- }
-
- ///
- /// Gets or sets the currently selected date.
- ///
- ///
- /// The date currently selected. The default is null.
- ///
- ///
- /// The specified date is not in the range defined by
- ///
- /// and
- /// ,
- /// or the specified date is in the
- ///
- /// collection.
- ///
- public DateTime? SelectedDate
- {
- get => _selectedDate;
- set => SetAndRaise(SelectedDateProperty, ref _selectedDate, value);
- }
-
- ///
- /// Gets or sets the format that is used to display the selected date.
- ///
- ///
- /// The format that is used to display the selected date. The default is
- /// .
- ///
- ///
- /// An specified format is not valid.
- ///
- public CalendarDatePickerFormat SelectedDateFormat
- {
- get => GetValue(SelectedDateFormatProperty);
- set => SetValue(SelectedDateFormatProperty, value);
- }
-
- public string CustomDateFormatString
- {
- get => GetValue(CustomDateFormatStringProperty);
- set => SetValue(CustomDateFormatStringProperty, value);
- }
-
- ///
- /// Gets or sets the text that is displayed by the
- /// .
- ///
- ///
- /// The text displayed by the
- /// .
- ///
- ///
- /// The text entered cannot be parsed to a valid date, and the exception
- /// is not suppressed.
- ///
- ///
- /// The text entered parses to a date that is not selectable.
- ///
- public string? Text
- {
- get => _text;
- set => SetAndRaise(TextProperty, ref _text, value);
- }
-
- ///
- public string? Watermark
- {
- get => GetValue(WatermarkProperty);
- set => SetValue(WatermarkProperty, value);
- }
-
- ///
- public bool UseFloatingWatermark
- {
- get => GetValue(UseFloatingWatermarkProperty);
- set => SetValue(UseFloatingWatermarkProperty, value);
- }
-
- ///
- /// Gets or sets the horizontal alignment of the content within the control.
- ///
- public HorizontalAlignment HorizontalContentAlignment
- {
- get => GetValue(HorizontalContentAlignmentProperty);
- set => SetValue(HorizontalContentAlignmentProperty, value);
- }
-
- ///
- /// Gets or sets the vertical alignment of the content within the control.
- ///
- public VerticalAlignment VerticalContentAlignment
- {
- get => GetValue(VerticalContentAlignmentProperty);
- set => SetValue(VerticalContentAlignmentProperty, value);
- }
-
///
/// Occurs when the drop-down
/// is closed.