Binding with an escaped string format breaks VS IDE and intellisense
In Silverlight, I've got a hyperlinkbutton defined as the following:
<HyperlinkButton Content="{Binding FileName}" NavigateUri="{Binding MailLogAttachmentID, StringFormat=\/DownloadFile.aspx?objecttype\=proposalattachment&id\=\{0\}}" />
When I try to view the designer, instead of the XAML, I get a Unhandled Exception has occurred error (Index (zero based) must be greater than or equal to zero and less than the size of the argument list) and it gives me the option of reloading the designer. This also breaks any intellisense while developing in XAML. If I remove the NavigateUri StringFormat expression, all is well. The application compiles fine and the hyperlink button works as expected.
Is there another way 开发者_C百科I can get this functionality without breaking the designer?
This should do the trick, if you don't want a complicated escaped expression:
<HyperlinkButton DataContext="{StaticResource s}" Content="{Binding FileName}">
<HyperlinkButton.NavigateUri>
<Binding Path="MailLogAttachmentID"
StringFormat="/DownloadFile.aspx?objecttype=proposalattachment&id={0}" />
</HyperlinkButton.NavigateUri>
</HyperlinkButton>
In any case, the character that was generating the exception was the ampersand, so if you write it like this, it should work too:
<HyperlinkButton Content="{Binding FileName}"
NavigateUri="{Binding MailLogAttachmentID, StringFormat=/DownloadFile.aspx?objecttype\=proposalattachment&amp;id\={0}}" />
精彩评论