Having converted an application from WPF to Silverlight, Visual Studio is indicating a strange compiler error in one of the XAML files:
Error 11 Unexpected Token after end of Markup Extension.
There is no indication as to which line is causing the error, but the offending code seems to be this:
<DataTemplate x:Key="ToolTipTemplate">
<StackPanel Orientation="Horizontal">
<TextBlock
Text="{Binding DataPoint.DataItem.Date,StringFormat={}{0:MM/dd/yyyy}}"
Foreground="{StaticResource ResourceKey=OtherColor}" />
<TextBlock
Text="{Binding DataPoint.DataItem.Price,StringFormat={}{0:0.00#}}"
Foreground="{StaticResource ResourceKey=OtherColor}"/>
</StackPanel>
</DataTemplate>
What could be the cause of this error?
The problem is the StringFormat
value -- WPF can tolerate it not being wrapped in single-quotes, but apparently Silverlight cannot.
Changing this:
<TextBlock Text="{Binding DataPoint.DataItem.Price,StringFormat={}{0:0.00#}}" />
to this:
<TextBlock Text="{Binding DataPoint.DataItem.Price,StringFormat='{}{0:0.00#}'}" />
^ ^
removes the error.
Put this down as a hazard of converting from WPF to Silverlight.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With