我尝试使用 @bind-Value 和 @bind-Value:after 在绑定发生后调用方法,但我的代码要么出现错误,要么不会调用该方法。
这样我得到错误编译器错误 CS0407 '返回类型方法'有错误的返回类型
<MudCheckBox Label="@R["Show title"]" Disabled="(!MayEdit && !MayDelete)" @bind-Value="@OptionsModel.Title_Visible" T="bool" @bind-Value:after="IsDirty"></MudCheckBox>
如果我在方法中添加括号,它会抱怨编译器错误 CS1503 参数“1”无法从“bool”转换为“System.Action”
如果我将它放入 lambda 中,它将编译,但当复选框更改时不会调用该方法
<MudCheckBox Label="@R["Show title"]" Disabled="(!MayEdit && !MayDelete)" @bind-Value="@OptionsModel.Title_Visible" T="bool" @bind-Value:after="(() => IsDirty())"></MudCheckBox>
方法在类文件ChartPropertyView.razor.cs中,Checkbox在ChartPropertyView.cs中
public override bool IsDirty()
IsDirty() 在 VS Professional 2022 V.17.7.7 中不会变成黄色,并且无法像平常一样悬停以获取信息