Unexplained error: "Unexpected token after the end of the markup extensions"

When converting an application from WPF to Silverlight, Visual Studio indicates a strange compiler error in one of the XAML files:

Error 11 An unexpected token after the end of the markup extension.

There is no indication as to which line is causing the error, but the violation code is as follows:

<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 causing this error?

+6
source share
1 answer

The problem is the value of StringFormat - WPF can tolerate this without being wrapped in single quotes, but Silverlight apparently cannot.

Change this:

 <TextBlock Text="{Binding DataPoint.DataItem.Price,StringFormat={}{0:0.00#}}" /> 

:

 <TextBlock Text="{Binding DataPoint.DataItem.Price,StringFormat='{}{0:0.00#}'}" /> ^ ^ 

removes the error.

Put this as a danger of converting from WPF to Silverlight.

+17
source

Source: https://habr.com/ru/post/950291/


All Articles