Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set default type @typeparam TValue = bool in blazor(.razor page)

Tags:

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;
like image 515
M K Avatar asked Feb 03 '20 05:02

M K


1 Answers

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
like image 137
Abdelrahman Gobarah Avatar answered Sep 20 '22 22:09

Abdelrahman Gobarah