levitali / CompiledBindings

MIT License
279 stars 14 forks source link

x:Bind string interpolation error #25

Closed salk52 closed 1 year ago

salk52 commented 1 year ago

I have this line of code in WPF app

<TextBox Text="{x:Bind $'String value: {Username}'}" />

and compiler is throwing error

error MC3043: Names and Values in a MarkupExtension cannot contain quotes. The MarkupExtension arguments ' $'String value: {Username}'

I'm using VS 17.5.5 and I don't know whats the problem. Does anyone else has this problem? Am I missing something?

levitali commented 1 year ago

You have to use the m: Namespace

  xmlns:m="http://compiledbindings.com"
  mc:Ignorable="d m"
  <TextBox m:Text="{x:Bind $'String value: {Username}'}" />

Alternatively you can use square brackets instead of curly ones.

  <TextBox Text="[x:Bind $'String value: {Username}']" />

The second option I do not have yet in readme.

salk52 commented 1 year ago

I was missing m: in front of text as I was looking this example from README <Label Text="{x:Bind $'Decimal value: {DecimalProp:0.###}, Boolean value: {BooleanProp}, String value: {StringProp.TrimStart('0')}'}" /> which is missing that m: in front of text :)