おい。ユーザーが検索できるアイテムのリストがあります。検索結果はリストボックスに表示されます。各animal
オブジェクトには、Isolated Storage 内のイメージへのパスがあります。listboxitem 内のイメージ コントロールを分離ストレージ内のイメージにバインドする最も簡単な方法は何ですか? 私が見た例では、Isolated Storage ではなく、インターネットからの画像を表示する傾向があります。約 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 を使用したことがないので、どんな助けも素晴らしいでしょう. ありがとう