0
我需要找到將圖像保存到IsolatedStorage並向他們顯示的方式Silverlight(XAML) 重要提示:Silverlight必須拍攝「自己」圖像,我無法設置圖像從後面的代碼 我以前嘗試過很多解決方案。 的最後的解決方案是,結合字節數組,並將它們轉換爲圖像 XAMLWindows Phone 7從IsolatedStorage Silverlight綁定圖像
StackPanel Orientation="Horizontal" Margin="0,0,0,20">
<Image Width="110" CacheMode="BitmapCache" Source="{Binding ThumbLocal,Converter={StaticResource imgConverter}}"
Margin="12,0,9,0"/>
<StackPanel Width="311">
代碼背後
public byte[] ThumbLocal
{
get;
set;
}
public class ByteImageConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
MemoryStream memStream = new MemoryStream((byte[])value);
memStream.Seek(0, SeekOrigin.Begin);
BitmapImage thumbLocal = new BitmapImage();
thumbLocal.SetSource(memStream);
return thumbLocal;
}
}
的一切工作,直到我保存byte[]
到數據庫中,並試圖找回。 現在我可以看到將圖像保存爲IsolatedStorage的唯一選項,然後檢索並隱藏到byte[]
。 這是「智能」解決方案嗎?