Table of Contents

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

OpenTo

Properties

AdditionalDateClassesFunc

The function which returns CSS classes for a date.

[Parameter]
[Category("Appearance")]
public Func<DateTime, string> AdditionalDateClassesFunc { get; set; }

Property Value

Func<DateTime, string>

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

bool

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

int

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

string

DisplayMonths

The number of months to display in the calendar.

[Parameter]
[Category("Picker behavior")]
public int DisplayMonths { get; set; }

Property Value

int

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

DayOfWeek?

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

Func<DateTime, bool>

Remarks

Defaults to null.
When set, a date will be disabled if the function returns true.

IsRange

protected virtual bool IsRange { get; }

Property Value

bool

MaxDate

The maximum selectable date.

[Parameter]
[Category("Validation")]
public DateTime? MaxDate { get; set; }

Property Value

DateTime?

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

DateTime?

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

string

Remarks

Defaults to ChevronRight.

OpenTo

The initial view to display.

[Parameter]
[Category("Picker behavior")]
public OpenTo OpenTo { get; set; }

Property Value

OpenTo

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

RenderFragment

PickerMonth

The current month shown in the date picker.

[Parameter]
[Category("Picker behavior")]
public DateTime? PickerMonth { get; set; }

Property Value

DateTime?

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

EventCallback<DateTime?>

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

string

Remarks

Defaults to ChevronLeft.

ScrollManager

[Inject]
protected IScrollManager ScrollManager { get; set; }

Property Value

IScrollManager

ShowWeekNumbers

Shows week numbers at the start of each week.

[Parameter]
[Category("Picker behavior")]
public bool ShowWeekNumbers { get; set; }

Property Value

bool

Remarks

Defaults to false.

StartMonth

The start month when opening the picker.

[Parameter]
[Category("Picker behavior")]
public DateTime? StartMonth { get; set; }

Property Value

DateTime?

TitleDateFormat

The format of the selected date in the title.

[Parameter]
[Category("Picker behavior")]
public string TitleDateFormat { get; set; }

Property Value

string

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

Task

FormatTitleDate(DateTime?)

protected string FormatTitleDate(DateTime? date)

Parameters

date DateTime?

Returns

string

GetAbbreviatedDayNames()

return Mo, Tu, We, Th, Fr, Sa, Su in the right culture

protected IEnumerable<string> GetAbbreviatedDayNames()

Returns

IEnumerable<string>

GetCalendarStartOfMonth()

protected abstract DateTime GetCalendarStartOfMonth()

Returns

DateTime

GetCalendarYear(DateTime)

Converts gregorian date into whatever year it is in the provided culture

protected abstract int GetCalendarYear(DateTime yearDate)

Parameters

yearDate DateTime

Gregorian Date

Returns

int

Year according to culture

GetDayClasses(int, DateTime)

protected abstract string GetDayClasses(int month, DateTime day)

Parameters

month int
day DateTime

Returns

string

GetFirstDayOfWeek()

protected DayOfWeek GetFirstDayOfWeek()

Returns

DayOfWeek

GetFormattedYearString()

protected string GetFormattedYearString()

Returns

string

GetMonthEnd(int)

Get the last of the month to display

protected DateTime GetMonthEnd(int month)

Parameters

month int

Returns

DateTime

GetMonthName(int)

protected string GetMonthName(int month)

Parameters

month int

Returns

string

GetMonthStart(int)

Get the first of the month to display

protected DateTime GetMonthStart(int month)

Parameters

month int

Returns

DateTime

GetNextView()

protected virtual OpenTo? GetNextView()

Returns

OpenTo?

GetTitleDateString()

protected abstract string GetTitleDateString()

Returns

string

GetWeek(int, int)

Gets the n-th week of the currently displayed month.

protected IEnumerable<DateTime> GetWeek(int month, int index)

Parameters

month int

offset from _picker_month

index int

between 0 and 4

Returns

IEnumerable<DateTime>

OnAfterRenderAsync(bool)

protected override Task OnAfterRenderAsync(bool firstRender)

Parameters

firstRender bool

Returns

Task

OnDayClickedAsync(DateTime)

User clicked on a day

protected abstract Task OnDayClickedAsync(DateTime dateTime)

Parameters

dateTime DateTime

Returns

Task

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

Task

OnPickerOpenedAsync()

protected override Task OnPickerOpenedAsync()

Returns

Task

OnYearClickedAsync(int)

user clicked on a year

protected virtual Task OnYearClickedAsync(int year)

Parameters

year int

Returns

Task

ScrollToYear()

Scrolls to the current year.

public void ScrollToYear()

SetCulture(CultureInfo)

protected override bool SetCulture(CultureInfo value)

Parameters

value CultureInfo

Returns

bool

SubmitAndCloseAsync()

protected virtual Task SubmitAndCloseAsync()

Returns

Task