2

I'm trying to do this

<MatCheckbox @bind-Value="@(!Checked)" Label="Checkbox"></MatCheckbox>

But it gives me the error

CS0131 The left-hand side of an assignment must be a variable, property or indexer

How can I pass a negated boolean value without creating another property?

I want to bind the value so it's !Checked

4

1 回答 1

2

As @DavidG said in the comments, you cannot bind a value, you need to bind a property, and !Checked returns a value, not a property.

So the only way to do this is by creating a negated property.

于 2020-03-09T14:22:12.353 回答