In Windows Metro Apps (C#), I'm using a ValueConverter to pass an Image-Uri like this:
public class ProfileImage : IValueConverter {
public Object Convert(Object value, Type targetType, Object parameter, String language) {
if (value == null) {
return "Common/images_profile/user.png";
}
return "ms-appdata:///local/" + (String)value;
}
public Object ConvertBack(Object value, Type targetType, Object parameter, String language) {
return value;
}
}
XAML:
<Image x:Name="profileImage" Height="80" Width="80" Source="{Binding Path, Converter={StaticResource ProfileImage}}"/>
The images are being downloaded async into localFolder.
I wanted to use this on Windows Phone 8 - but it doesn't show up any image.
var localFolder = ApplicationData.Current.LocalFolder;
StorageFile myFile = await localFolder.CreateFileAsync(
UID + ".jpg",
CreationCollisionOption.FailIfExists);
using (var s = await myFile.OpenStreamForWriteAsync()) {
s.Write(imageBytes, 0, imageBytes.Length);
}
is used for writing the Images to the LocalStorage.
If there's no content in value
, the Image in Common/images_profile/user.png
is being displayed properly. This one is in the package, not in the local Folder.
I need to know which format I have to use as return parameter to get the images displayed.