What Changed
The DxCalendar class became generic-typed.
Old:
C#public class DxCalendar {...}
New:
C#public class DxCalendar<T> {...}
The SelectedDates property and the SelectedDatesChanged event changed their signature.
Old:
C#public IEnumerable<DateTime> SelectedDates { get; set; }
public Action<IEnumerable<DateTime>> SelectedDatesChanged { get; set; }
New:
C#public IEnumerable<T> SelectedDates { get; set; }
public EventCallback<IEnumerable<T>> SelectedDatesChanged { get; set; }
Reasons for Change
In previous versions, the Calendar component operated with the DateTime type only. In v20.1.6, we made this component generic-typed and updated the required API to support both the DateTime and Nullable DateTime types.
Impact on Existing Apps
This change will affect your application in the following cases:
- If you add the DxCalendar component to markup and do not use two-way binding.
Razor<DxCalendar/>
- If you create the component in C# code via RenderTreeBuilder.
C#builder.OpenComponent<DxCalendar>(seq++)
Your code with the SelectedDates property will compile and work without changes. For information on how to update the SelectedDatesChanged event, refer to the following Breaking Change: T920147
How to Update Existing Apps
If you use the component in markup, do either of the following:
- Specify the component data type explicitly.
Razor<DxCalendar T="DateTime"/>
- Specify two-way binding for the SelectedDate or SelectedDates property.
Razor<DxCalendar @bind-SelectedDate="@SelectedDate" />
@code {
DateTime selectedDate = DateTime.Now;
DateTime SelectedDate { get => selectedDate; set { selectedDate = value; InvokeAsync(StateHasChanged); } }
}
If you create the Calendar component in C# code, specify the component type as follows:
- for the DateTime type:
C#builder.OpenComponent<DxCalendar<DateTime>>(seq++);
- for the Nullable DateTime type:
C#builder.OpenComponent<DxCalendar<DateTime?>>(seq++);