Skip to content

Add ability to pass @typeparam down to child components #7268

Closed
@ivanchev

Description

@ivanchev

Is your feature request related to a problem? Please describe.

If you have a templated component, that's Generic and uses @typeparam, if you want to add other child components, you also have to specify the type when you declare them. For instance in a Grid:

<Grid Data=List<Item>>
  <Columns>
    <Column TItem=Item>
      <Template />
    </Column>
  </Columns>
</Grid>

In this setup, in order to have a strongly typed context passed to the Column templates, you have to specify explicitly TItem to each Column and cannot be inferred by the List.

Describe the solution you'd like

With the current setup we can pass simple parameters down to child components with:

<CascadingValue Value=this>
    @Columns
</CascadingValue>

I would like to have the ability to aslo pass down @typeparam values. Perhaps something like:

<CascadingType Value=TItem>
    @Columns
</CascadingType>

And if the child component declares it's own TItem, it will override the Cascading value.

Metadata

Metadata

Labels

Components Big RockThis issue tracks a big effort which can span multiple issuesNeeds: DesignThis issue requires design work before implementating.affected-fewThis issue impacts only small number of customersarea-blazorIncludes: Blazor, Razor Componentscomponent ecosystemIndicates an issue which also has impact on 3rd party component ecosystemenhancementThis issue represents an ask for new feature or an enhancement to an existing oneseverity-blockingThis label is used by an internal tool

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions