bkmtan
bkmtan

Reputation: 101

WPF StringFormat={}{0:N} Error "Expected '"

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

Upvotes: 4

Views: 3653

Answers (4)

Ben Gribaudo
Ben Gribaudo

Reputation: 5147

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\}

Upvotes: 4

Ray Burns
Ray Burns

Reputation: 62919

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.

Upvotes: 0

Steven
Steven

Reputation: 4963

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

Upvotes: 0

Matt Hamilton
Matt Hamilton

Reputation: 204229

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

<TextBlock Text="{Binding StringFormat='{}{0:N}'}" />

Upvotes: 7

Related Questions