What if we were required to explicitly define page properties and set their types instead of relying on the Set Property action in addition to other ways RadZen magically adds properties to pages.
The Set Property
action is the only way to create a property in Radzen. It is still explicit and there is no magic around it. If you don't like that you can define properties in the partial class. Radzen detects such properties.
Also changing the way properties are defined in Radzen will not solve this particular issue. It is caused by the way Blazor infers the type of a generic component. Check this thread for example: Basic property setting of TextBox Value not binding - #21 by korchev - a few very similar definitions - some of them compile without specifying the generic argument, some don't.
Microsoft tell developers to just set the generic argument if the compiler fails to infer it. Our workaround with the Attributes does exactly that. A better solution would be to set that automatically from Radzen when the user sets the Value property of a component. We will implement that at some point - already doing a similar thing for the Data property of components with items.
For example, in page built from nested grid wizard, the data property of the nested grid is set to
${rzNwModelsInventoryShipment.ShipmentItems}
This is to allow you to have nested template contexts. Consider this:
<RadzenGridColumn>
<Template Context="data">
<RadzenGrid Data="@data.Items">
<RadzenGridColumn>
<Template Context="data">
</Template>
</RadzenGrid>
</Template>
</RadzenGridColumn>
In this case the inner Context="data"
won't work as "data" is defined already. Radzen generates unique name for the context. In design time you still use ${data}
.