Lead Product Evangelist @Kentico, Founding partner @craftbrewingbiz. love to learn / teach web dev & software engineering, collecting vinyl records, mowing my lawn, craft 🍺
The key to the pattern matching is to 'exit early' if the type isn't correct. That was C# will know that in the rest of the View, the type is what you expect
@model ComponentViewModel<YourPageTemplatePropertiesType>
@if (Model.Page is not YourPageType myPage)
{
return;
}
<!-- from here on, C# knows Model.Page is YourPageType and myPage is safely typecast as YourPageType --><vc:your-view-componentpage="myPage"props="Model.Properties"/>
Dave,
The key to the pattern matching is to 'exit early' if the type isn't correct. That was C# will know that in the rest of the View, the type is what you expect