Home Dashboard Directory Help
Search

Cider/VS2010 Designer Bug with Binding using escaped entities in StringFormat by HungryDwarf


Status: 

Closed
 as External Help for as External


1
0
Sign in
to vote
Type: Bug
ID: 782059
Opened: 3/25/2013 11:02:23 AM
Access Restriction: Public
1
Workaround(s)
view
0
User(s) can reproduce this bug

Description


(NOTE: This happens in VS2010, not sure if present in VS2012)


If you declare a data binding using the StringFormat argument, and that StringFormat has one of a select number of escaped XML entities, it causes a Designer error/crash.


Ex:
<!-- should show '&Value', but crashes the designer -->
<TextBlock Text="{Binding Path=Value, StringFormat=&{0}}"/>


Stack Trace shows that it's actually an unhandled exception in the error reporting method for the parser:


System.FormatException
Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
at System.Text.StringBuilder.AppendFormat(IFormatProvider provider, String format, Object[] args)
at System.String.Format(IFormatProvider provider, String format, Object[] args)
at MS.Internal.Design.DocumentModel.DocumentTrees.Markup.XamlParseContext.ErrorWrapper.ConvertError(Error error, Object[] args)
at MS.Internal.Design.DocumentModel.DocumentTrees.Markup.XamlParseContext.ReportError(Error error, MarkupErrorMessageCategory category, Int32 offset, Int32 length, Object[] args)
at MS.Internal.Design.DocumentModel.DocumentTrees.Markup.XamlParseContext.ReportError(Error error, Int32 offset, Int32 length, Object[] args)
at MS.Internal.Design.Markup.MarkupExtensionParser.HandleError(Int32 start, Error error, Object[] args)
at MS.Internal.Design.Markup.MarkupExtensionParser.ScanXmlEscapedChar(Int32 current, Char& ch)
at MS.Internal.Design.Markup.MarkupExtensionParser.NextToken()
at MS.Internal.Design.Markup.MarkupExtensionParser.Expect(Char token)
at MS.Internal.Design.Markup.MarkupExtensionParser.ParseNamedArguments(TypeNode type, List`1 arguments)
at MS.Internal.Design.Markup.MarkupExtensionParser.ParseExtension()
at MS.Internal.Design.Markup.MarkupExtensionParser.Parse()
at MS.Internal.Design.Markup.XmlElement.ConvertMarkupExtension(XamlAttribute attribute, XmlItem valueNode, PrefixScope scope, IParseContext context)


(rest of trace omitted)


Note that the following *doesn't* crash the designer, and the designer will show the "expected" visual, but at runtime, the extra escaping causes incorrect behavior:


<!-- works in designer (shows &Value), shows &Value at runtime -->
<TextBlock Text="{Binding Path=Value, StringFormat=&{0}}"/>

Details
Sign in to post a comment.
Posted by Microsoft on 3/25/2013 at 11:47 PM
Hi HungryDwarf, thank you for submitting feedback on Visual Studio and .NET Framework. We'll close this feedback because there is a workaround on this issue. Thanks a lot for sending the workaround.
Posted by Microsoft on 3/25/2013 at 11:51 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Posted by HungryDwarf on 3/25/2013 at 11:08 AM
I obviously fail at connect-form-entry markup; any benevolent souls in the know willing to edit/format my post?
Sign in to post a workaround.
Posted by HungryDwarf on 3/25/2013 at 11:07 AM
Workarounds include: 1. Explicit binding XAML (i.e., not inline - as a distinct subelement, the escaping of entities works properly in StringFormat) 2. Multibinding, passing in the "ampersand value" as one parameter 3. Eschewing designer support, since the correct runtime behavior happens regardless.