5
votes

We have provided the TValue support in the checked property for the Checkbox component. How to set default type @typeparam TValue = bool in blazor(.razor page)

@using Microsoft.AspNetCore.Components.Web;
@using Microsoft.AspNetCore.Components.Rendering
@inherits BaseComponent;
@implements ICheckBox;
@typeparam TValue = bool;
1
The answer is really good. You should accept it. - henon

1 Answers

4
votes

This is a known issue https://github.com/dotnet/aspnetcore/issues/13619

but work around I do in a project is

public class DateTimePickerComponent : DateTimePickerComponent<DateTime?> { } // default Type value

public class DateTimePickerComponent<T> : BaseSubComponent { .... } // all business here

and in Component I inherts from one of

@inherits DateTimePickerComponent  // default type will be DateTime?
@inherits DateTimePickerComponent<DateTime> // this also work