代码之家  ›  专栏  ›  技术社区  ›  Sascha

绑定到图像

  •  0
  • Sascha  · 技术社区  · 14 年前

    我使用的是一个列表框,模板如下。

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

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

    萨沙

    1 回复  |  直到 14 年前
        1
  •  0
  •   Wouter Janssens    14 年前

    以前从未见过这种情况,但绑定在默认情况下会抑制错误。当出现错误时,在VisualStudio的输出窗口中运行debug en watch时可以看到错误,并确保组合框“Show output from:”的选项设置为“debug”

    编辑时间:

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