使用StringFormat绑定时Visual Studio 2010设计器中的错误

时间:2011-01-17 00:02:00

标签: silverlight visual-studio-2010 data-binding string-formatting

我正在使用Silverlight,在我的xaml中,我尝试使用StringFormat绑定一个Image源,如WPF Image Dynamically changing Image source during runtime中的示例

但是当我添加'& amp;'时在我的网址中有一个错误说: 在“ProductView.xaml”上抛出System.FormatException:索引(从零开始)必须大于或等于零且小于参数列表的大小。

这是我的图片标签i xaml:

<Image Width="100" Height="100" Source="{Binding Image.ResourceFileId, StringFormat='http://URL/images?id={0}&amp;format=thumbnail'}" />

删除'&amp; amp;' - 部分时没有错误,应用程序编译并运行有和没有'&amp; amp;' - 部分。这只是设计器中的一个错误,但效果是当此错误“激活”时,IntelliSense似乎不再起作用。

有没有人对此有解释?

1 个答案:

答案 0 :(得分:1)

我认为大括号是给你一个问题的原因。它看起来应该是这样的:

StringFormat='http://URL/images?id=\{0\}&amp;format=thumbnail'