Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unexplained error: "Unexpected Token after end of Markup Extensions"

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?

like image 794
McGarnagle Avatar asked Jul 25 '13 17:07

McGarnagle


1 Answers

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.

like image 166
McGarnagle Avatar answered Nov 17 '22 00:11

McGarnagle