Table of Contents

Class TwCalendarMonthView<T>

Namespace
TwBlazor.Components
Assembly
TwBlazor.dll

Renders a full month grid (5 or 6 weeks, however many the month actually spans - see TwBlazor.Components.TwCalendarMonthView`1.GetWeekRows) with each day's events shown as small chips, following the same <table role="grid">/roving-tabindex/arrow-key pattern as TwDatePickerDayView.

public class TwCalendarMonthView<T> : TwBlazorComponentBase, IComponent, IHandleEvent, IHandleAfterRender, ITwComponent, IAsyncDisposable

Type Parameters

T

The type of Value for the events shown.

Inheritance
TwCalendarMonthView<T>
Implements
Inherited Members

Constructors

TwCalendarMonthView()

public TwCalendarMonthView()

Properties

Date

Any date within the month to display.

[Parameter]
[EditorRequired]
public DateTime Date { get; set; }

Property Value

DateTime

DraggedEvent

The event being dragged once the drag is live; a placeholder for it is drawn in the hovered day.

[Parameter]
public Schedule<T>? DraggedEvent { get; set; }

Property Value

Schedule<T>

DropPreview

The day DraggedEvent would land on if released now.

[Parameter]
public DateTime? DropPreview { get; set; }

Property Value

DateTime?

Editable

When true, non-read-only events can be dragged between days (their time-of-day and duration stay unchanged - only the date moves).

[Parameter]
public bool Editable { get; set; }

Property Value

bool

EventContentTemplate

Optional custom rendering for an event's chip content; defaults to just Name.

[Parameter]
public RenderFragment<Schedule<T>>? EventContentTemplate { get; set; }

Property Value

RenderFragment<Schedule<T>>

HighlightDate

A day whose cell pulses, used to draw the eye to today after "Today" is pressed. Leave null for no highlight.

[Parameter]
public DateTime? HighlightDate { get; set; }

Property Value

DateTime?

JSRuntime

[Inject]
public IJSRuntime JSRuntime { get; set; }

Property Value

IJSRuntime

OnDayClick

Invoked with a day's date when its day number or "+N more" overflow label is clicked - typically wired up by TwCalendar<T> to switch to the Day view for that date.

[Parameter]
public EventCallback<DateTime> OnDayClick { get; set; }

Property Value

EventCallback<DateTime>

OnEventClick

Invoked with the event when one of its chips is clicked.

[Parameter]
public EventCallback<Schedule<T>> OnEventClick { get; set; }

Property Value

EventCallback<Schedule<T>>

OnEventDragEnd

Invoked when a drag ends, whether or not it was dropped on a valid target.

[Parameter]
public EventCallback OnEventDragEnd { get; set; }

Property Value

EventCallback

OnEventDragOver

Invoked with the hovered day when a dragged event enters one of its cells.

[Parameter]
public EventCallback<DateTime> OnEventDragOver { get; set; }

Property Value

EventCallback<DateTime>

OnEventDragStart

Invoked with an event when dragging it starts. See TwCalendar<T>'s OnEventDragStart/OnEventDrop remarks.

[Parameter]
public EventCallback<Schedule<T>> OnEventDragStart { get; set; }

Property Value

EventCallback<Schedule<T>>

OnEventDrop

Invoked with a day's date (time-of-day irrelevant - TwCalendar<T> keeps the dragged event's original time-of-day) when it's dropped on that day's cell.

[Parameter]
public EventCallback<DateTime> OnEventDrop { get; set; }

Property Value

EventCallback<DateTime>

Schedules

The full event list; filtered per day before being rendered in each cell.

[Parameter]
public List<Schedule<T>> Schedules { get; set; }

Property Value

List<Schedule<T>>

Methods

BuildRenderTree(RenderTreeBuilder)

Renders the component to the supplied RenderTreeBuilder.

protected override void BuildRenderTree(RenderTreeBuilder __builder)

Parameters

__builder RenderTreeBuilder

DisposeAsync()

public ValueTask DisposeAsync()

Returns

ValueTask

OnAfterRenderAsync(bool)

Method invoked after each time the component has been rendered interactively and the UI has finished updating (for example, after elements have been added to the browser DOM). Any ElementReference fields will be populated by the time this runs.

This method is not invoked during prerendering or server-side rendering, because those processes are not attached to any live browser DOM and are already complete before the DOM is updated.

Note that the component does not automatically re-render after the completion of any returned Task, because that would cause an infinite render loop.

protected override Task OnAfterRenderAsync(bool firstRender)

Parameters

firstRender bool

Set to true if this is the first time OnAfterRender(bool) has been invoked on this component instance; otherwise false.

Returns

Task

A Task representing any asynchronous operation.

Remarks

The OnAfterRender(bool) and OnAfterRenderAsync(bool) lifecycle methods are useful for performing interop, or interacting with values received from @ref. Use the firstRender parameter to ensure that initialization work is only performed once.

OnParametersSet()

Invoked when the component's parameters have been set. Ensures that the component has a unique identifier by generating one if none is provided.

protected override void OnParametersSet()

Remarks

If the component's identifier is not set, a unique ID is generated based on the component's type name (with a 'Tw' prefix removed if present) and a GUID. This helps ensure that each component instance can be uniquely identified, which is useful for scenarios such as associating labels with form elements or targeting elements in client-side scripts.