绑定到图像

时间:2010-08-09 12:04:41

标签: wpf listbox

我正在使用带有如下模板的列表框。

<ListBox.ItemTemplate>
    <DataTemplate>
        <Image Source="{Binding}" Width="100" />
    </DataTemplate>
</ListBox.ItemTemplate>

我将它绑定到一个可观察的集合,其中包含130个映像路径(所有存在,使用System.IO.Directory读取)但只有少数真正显示。没有例外。只有白色的地方应该是图像。有没有人看到别的东西。

的Sascha

1 个答案:

答案 0 :(得分:0)

之前从未见过这个,但Binding默认会抑制错误。当出现错误时,您可以在visual studio的输出窗口中运行debug en watch时看到它们,并确保组合框“Show output from:”的选项设置为“Debug”

希望这能帮助你解决真正的问题。

已编辑:

如果您没有看到问题,可以通过挂钩到Image.ImageFailed事件找到它。可以在这里找到更多帮助:

http://msdn.microsoft.com/en-us/library/system.windows.controls.image.imagefailed%28v=VS.95%29.aspx