Class MudBaseDatePicker
- Namespace
- MudBlazor
- Assembly
- MudBlazor.dll
Represents a base class for designing date picker components.
public abstract class MudBaseDatePicker : MudPicker<DateTime?>, IComponent, IHandleEvent, IHandleAfterRender, IMudStateHasChanged, IFormComponent, IAsyncDisposable
- Inheritance
-
MudBaseDatePicker
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
MudBaseDatePicker()
protected MudBaseDatePicker()
Fields
CurrentView
protected OpenTo CurrentView
Field Value
Properties
AdditionalDateClassesFunc
The function which returns CSS classes for a date.
[Parameter]
[Category("Appearance")]
public Func<DateTime, string> AdditionalDateClassesFunc { get; set; }
Property Value
Remarks
Multiple classes must be separated by spaces.
AutoClose
Closes this picker when a value is selected.
[Parameter]
[Category("Picker behavior")]
public bool AutoClose { get; set; }
Property Value
Remarks
Defaults to false
.
ClosingDelay
The delay, in milliseconds, before closing the picker after a value is selected.
[Parameter]
[Category("Picker behavior")]
public int ClosingDelay { get; set; }
Property Value
Remarks
Defaults to 100
.
This delay helps the user see that a date has been selected before the popover disappears.
DateFormat
The format for selected dates.
[Parameter]
[Category("Behavior")]
public string DateFormat { get; set; }
Property Value
DisplayMonths
The number of months to display in the calendar.
[Parameter]
[Category("Picker behavior")]
public int DisplayMonths { get; set; }
Property Value
Remarks
Defaults to 1
.
FirstDayOfWeek
The day representing the first day of the week.
[Parameter]
[Category("Picker behavior")]
public DayOfWeek? FirstDayOfWeek { get; set; }
Property Value
Remarks
Defaults to the current culture's DateTimeFormat.FirstDayOfWeek
.
FixDay
The day to use, which cannot be changed.
[Parameter]
[Category("Picker behavior")]
public int? FixDay { get; set; }
Property Value
- int?
Remarks
Defaults to null
.
FixMonth
The month to use, which cannot be changed.
[Parameter]
[Category("Picker behavior")]
public int? FixMonth { get; set; }
Property Value
- int?
Remarks
Defaults to null
.
FixYear
The year to use, which cannot be changed.
[Parameter]
[Category("Picker behavior")]
public int? FixYear { get; set; }
Property Value
- int?
Remarks
Defaults to null
.
IsDateDisabledFunc
The function used to disable one or more dates.
[Parameter]
[Category("Validation")]
public Func<DateTime, bool> IsDateDisabledFunc { get; set; }
Property Value
Remarks
Defaults to null
.
When set, a date will be disabled if the function returns true
.
IsRange
protected virtual bool IsRange { get; }
Property Value
MaxDate
The maximum selectable date.
[Parameter]
[Category("Validation")]
public DateTime? MaxDate { get; set; }
Property Value
MaxMonthColumns
The maximum number of months allowed in one row.
[Parameter]
[Category("Picker appearance")]
public int? MaxMonthColumns { get; set; }
Property Value
- int?
Remarks
Defaults to null
.
When null
, the DisplayMonths is used.
MinDate
The minimum selectable date.
[Parameter]
[Category("Validation")]
public DateTime? MinDate { get; set; }
Property Value
NextIcon
The icon for the button which navigates to the next month or year.
[Parameter]
[Category("Picker appearance")]
public string NextIcon { get; set; }
Property Value
Remarks
Defaults to ChevronRight.
OpenTo
The initial view to display.
[Parameter]
[Category("Picker behavior")]
public OpenTo OpenTo { get; set; }
Property Value
Remarks
Defaults to Date.
PickerContent
Gets the content to be rendered inside the picker. Override this property to provide custom content for the picker.
protected override RenderFragment PickerContent { get; }
Property Value
PickerMonth
The current month shown in the date picker.
[Parameter]
[Category("Picker behavior")]
public DateTime? PickerMonth { get; set; }
Property Value
Remarks
Defaults to the current month.
When bound via @bind-PickerMonth
, controls the initial month displayed. This value is always the first day of a month.
PickerMonthChanged
Occurs when PickerMonth has changed.
[Parameter]
public EventCallback<DateTime?> PickerMonthChanged { get; set; }
Property Value
PreviousIcon
The icon for the button that navigates to the previous month or year.
[Parameter]
[Category("Picker appearance")]
public string PreviousIcon { get; set; }
Property Value
Remarks
Defaults to ChevronLeft.
ScrollManager
[Inject]
protected IScrollManager ScrollManager { get; set; }
Property Value
ShowWeekNumbers
Shows week numbers at the start of each week.
[Parameter]
[Category("Picker behavior")]
public bool ShowWeekNumbers { get; set; }
Property Value
Remarks
Defaults to false
.
StartMonth
The start month when opening the picker.
[Parameter]
[Category("Picker behavior")]
public DateTime? StartMonth { get; set; }
Property Value
TitleDateFormat
The format of the selected date in the title.
[Parameter]
[Category("Picker behavior")]
public string TitleDateFormat { get; set; }
Property Value
Remarks
Defaults to ddd, dd MMM
.
Supported date formats can be found here: https://learn.microsoft.com/dotnet/standard/base-types/standard-date-and-time-format-strings.
Methods
BuildRenderTree(RenderTreeBuilder)
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
__builder
RenderTreeBuilder
DateFormatChangedAsync(string)
Occurs when the DateFormat has changed.
protected virtual Task DateFormatChangedAsync(string newFormat)
Parameters
newFormat
string
Returns
FormatTitleDate(DateTime?)
protected string FormatTitleDate(DateTime? date)
Parameters
date
DateTime?
Returns
GetAbbreviatedDayNames()
return Mo, Tu, We, Th, Fr, Sa, Su in the right culture
protected IEnumerable<string> GetAbbreviatedDayNames()
Returns
GetCalendarStartOfMonth()
protected abstract DateTime GetCalendarStartOfMonth()
Returns
GetCalendarYear(DateTime)
Converts gregorian date into whatever year it is in the provided culture
protected abstract int GetCalendarYear(DateTime yearDate)
Parameters
yearDate
DateTimeGregorian Date
Returns
- int
Year according to culture
GetDayClasses(int, DateTime)
protected abstract string GetDayClasses(int month, DateTime day)
Parameters
Returns
GetFirstDayOfWeek()
protected DayOfWeek GetFirstDayOfWeek()
Returns
GetFormattedYearString()
protected string GetFormattedYearString()
Returns
GetMonthEnd(int)
Get the last of the month to display
protected DateTime GetMonthEnd(int month)
Parameters
month
int
Returns
GetMonthName(int)
protected string GetMonthName(int month)
Parameters
month
int
Returns
GetMonthStart(int)
Get the first of the month to display
protected DateTime GetMonthStart(int month)
Parameters
month
int
Returns
GetNextView()
protected virtual OpenTo? GetNextView()
Returns
GetTitleDateString()
protected abstract string GetTitleDateString()
Returns
GetWeek(int, int)
Gets the n-th week of the currently displayed month.
protected IEnumerable<DateTime> GetWeek(int month, int index)
Parameters
Returns
OnAfterRenderAsync(bool)
protected override Task OnAfterRenderAsync(bool firstRender)
Parameters
firstRender
bool
Returns
OnDayClickedAsync(DateTime)
User clicked on a day
protected abstract Task OnDayClickedAsync(DateTime dateTime)
Parameters
dateTime
DateTime
Returns
OnInitialized()
protected override void OnInitialized()
OnMonthClicked(int)
user clicked on a month
protected virtual void OnMonthClicked(int month)
Parameters
month
int
OnMonthSelectedAsync(DateTime)
user clicked on a month
protected virtual Task OnMonthSelectedAsync(DateTime month)
Parameters
month
DateTime
Returns
OnPickerOpenedAsync()
protected override Task OnPickerOpenedAsync()
Returns
OnYearClickedAsync(int)
user clicked on a year
protected virtual Task OnYearClickedAsync(int year)
Parameters
year
int
Returns
ScrollToYear()
Scrolls to the current year.
public void ScrollToYear()
SetCulture(CultureInfo)
protected override bool SetCulture(CultureInfo value)
Parameters
value
CultureInfo
Returns
SubmitAndCloseAsync()
protected virtual Task SubmitAndCloseAsync()