4

I'm getting an error in VS 2008 SP1 with WPF using the stringformat binding, is there an inherent problem with wpf in vs 2008?

Error 1 Expected ' ConstituentCrossrateGridControl.xaml 70 141 PriceViewWpfLibrary

bkmtan
  • 101
  • 1
  • 4
  • I have been involved in a number of WPF projects in VS 2008 (SP1) and have not encountered an "inherent" problem with WPF in VS 2008. – Dave White Jun 11 '10 at 03:07

4 Answers4

7

As the error message suggests, try wrapping your StringFormat value in single quotes. For example:

<TextBlock Text="{Binding StringFormat='{}{0:N}'}" />
Matt Hamilton
  • 200,371
  • 61
  • 386
  • 320
  • But that is invalid XAML: A markup extension may not include quotes of any kind. You always get the exception "Names and Values in a markup extension cannot contain quotes." Therefore his problem is something else. – Ray Burns Jun 11 '10 at 23:55
  • 3
    Maybe, but wrapping the StringFormat value in single quotes works fine for me, and I learned it from reading example code from Microsoft (though I don't remember where specifically). – Matt Hamilton Jun 13 '10 at 08:03
4

Visual Studio 2008 IDE's XAML syntax parser has several bugs where it complains that certain valid XAML is invalid.

Does this method of escaping work for you?

StringFormat=\{0:N\}
Ben Gribaudo
  • 5,057
  • 1
  • 40
  • 75
0

I believe it can only be used when the target property is of type String.

Steven
  • 4,826
  • 3
  • 35
  • 44
0

My guess is that you are opening your attribute value using a single quote but closing it using a double-quote. But that is only a guess.

Please post the referenced line of code so we can give you better feedback.

Ray Burns
  • 62,163
  • 12
  • 140
  • 141