Blazorの親から子へのデータバインドでエラーになった

コンポーネントのプロパティにバインドさせる場合に下記のように書くとエラーが出たことがあった。

※後日試したところエラーになったコードでもエラーにならなかった。また同じエラーが出たときのために残しておく

エラーになったコード

@*親コンポーネントから子コンポーネントBindChildのMentalプロパティにバインドする*@
<BlazorBlogBind.Components.BindChild @bind-Mental="Mental"/>


エラー内容

The attribute names could not be inferred from bind attribute 'bind-Mental'. Bind attributes should be of the form 'bind' or 'bind-value' along with their corresponding optional parameters like 'bind-value:event', 'bind:format' etc.


解消例1

<BlazorBlogBind.Components.BindChild @bind-Mental="Mental" @bind-Mental:event="MentalChanged"/>


解消例2

@*usingを追加する*@
@using BlazorBlogBind.Components
<BindChild @bind-Mental="Mental" />


参考

https://stackoverflow.com/questions/57528902/the-attribute-names-could-not-be-inferred-from-bind-attribute-bind-value-err