Back to Devexpress

DxCalendar<T>.SelectedDateExpression Property

blazor-devexpress-dot-blazor-dot-dxcalendar-1-6235cce9.md

latest2.9 KB
Original Source

DxCalendar<T>.SelectedDateExpression Property

Specifies a lambda expression that identifies the SelectedDate property’s bound value when the Calendar is placed in the EditForm.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
[Parameter]
public Expression<Func<T>> SelectedDateExpression { get; set; }

Property Value

TypeDescription
Expression<Func<T>>

A lambda expression that identifies the bound value.

|

Remarks

You can add the Calendar to Blazor’s standard EditForm component to validate the SelectedDate property value. In this case, the SelectedDateExpression property is used to obtain metadata about the value bound to the SelectedDate property.

You should specify the SelectedDateExpression property if you handle the SelectedDateChanged event and cannot use two-way binding.

razor
<DxCalendar SelectedDate="@SelectedDate"
            SelectedDateExpression="@(() => SelectedDate)"
            SelectedDateChanged="@((DateTime newValue) => SelectedDateChanged(newValue))">
</DxCalendar>

@code {
    DateTime SelectedDate { get; set; } = DateTime.Now;
    // ...
    void SelectedDateChanged(DateTime selectedDate) {
        // ...
    }
}

The SelectedDateExpression property is set internally if you use the @bind attribute for the SelectedDate property to implement two-way binding.

razor
<DxCalendar @bind-SelectedDate="@SelectedDate">
</DxCalendar>

@code {
    DateTime SelectedDate { get; set; } = DateTime.Now;
    // ...
}

The following exception occurs if you do not use two-way binding or the SelectedDateExpression property:

DevExpress.Blazor.DxCalendar requires a value for the ‘SelectedDateExpression’ property. It is specified automatically when you use two-way binding (‘bind-SelectedDate’).

See Also

DxCalendar<T> Class

DxCalendar<T> Members

DevExpress.Blazor Namespace