嘿。我有一个用户可以搜索的项目列表。搜索结果显示在列表框中。每个animal
对象都有一个指向独立存储中图像的路径。将 listboxitem 中的 Image 控件绑定到隔离存储中的图像的最快方法是什么?我见过的示例倾向于显示来自互联网而不是独立存储的图像。如果我有大约 10 张图像,它似乎会占用所有内存并崩溃。谢谢
编辑:
我在我的BitmapConverter
课堂上使用它(继承 IValueConverter)
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value !=null)
{
BitmapImage bitmapImage = new BitmapImage();
bitmapImage.SetSource(new MemoryStream((Byte[]) value));
return bitmapImage;
}
else
{
return null;
}
}
我在 AppResource.xaml 文件的顶部有这个:
<ImageApp_Converter:BitmapConverter x:Key="bmpConverter" />
In my style, within the AppResource.xaml file:
<Image HorizontalAlignment="Left" Margin="8,8,0,4" Width="160" Height="120" Source="{Binding Converter={StaticResource bmpConverter}}" />
我在我的 BitmapConverter 中设置了一个断点,但它从未被调用过。我以前从未使用过 IValueConverter,所以任何帮助都会很棒。谢谢