Skip to main content

DxCalendar<T>.SelectedDatesChanged Event

Fires after the selection is changed.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

Declaration

[Parameter]
public EventCallback<IEnumerable<T>> SelectedDatesChanged { get; set; }

Parameters

Type Description
IEnumerable<T>

A collection of selected dates.

Remarks

The SelectedDatesChanged event fires each time the SelectedDates collection changes.

<DxCalendar EnableMultiSelect="true"
            SelectedDates="SelectedDates"
            SelectedDatesChanged="@((IEnumerable<DateTime> newValue) => OnSelectedDatesChanged(newValue))" />

<p>Selected Dates:</p>

@foreach (DateTime date in SelectedDates)
{
    <p>
        @date.ToShortDateString()
    </p>
}

@code{
    List<DateTime> SelectedDates = new List<DateTime>();

    List<DateTime> GetSelectedDates()
    {
        DateTime baseDate = DateTime.Today;
        SelectedDates = new List<DateTime>
            () { baseDate.AddDays(-9), baseDate.AddDays(-5), baseDate.AddDays(-4),
                baseDate.AddDays(6), baseDate.AddDays(12), baseDate.AddDays(13),
                baseDate.AddDays(15) };
        return SelectedDates;
    }

    protected override void OnInitialized()
    {
        SelectedDates = GetSelectedDates();
    }

    void OnSelectedDatesChanged(IEnumerable<DateTime> selectedDates)
    {
        SelectedDates = selectedDates.ToList();
    }
}
See Also