Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Bind to byte Array from your ObservableCollection and use Converter so it will convert the image to a byte array
- class ImageConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, string language)
- {
- if (value == null || !(value is byte[]))
- return null;
- using (InMemoryRandomAccessStream ms = new InMemoryRandomAccessStream())
- {
- using (DataWriter writer = new DataWriter(ms.GetOutputStreamAt(0)))
- {
- writer.WriteBytes((byte[])value);
- writer.StoreAsync().GetResults();
- }
- var image = new BitmapImage();
- image.SetSource(ms);
- return image;
- }
- }
- public object ConvertBack(object value, Type targetType, object parameter, string language)
- {
- throw new NotImplementedException();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement