I bind byte array to image source in my windows phone application.
XAML:
<Border Background="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}" Margin="0,9.5,0,0" Grid.Column="0" HorizontalAlignment="Left">
<Image Source="{Binding EventPicture}" Stretch="UniformToFill" AutomationProperties.Name="{Binding Title}" Height="79" Width="79"/>
</Border>
It's a part of item template of ListView
in HubSection
. Items are bind from view model and it got them from service in json format.
Data retrieving code:
public async Task<ObservableCollection<SocialEvent>> GetSocialEventsAsync()
{
var socialEvents = new ObservableCollection<SocialEvent>();
var httpClient = new HttpClient();
var jsonResponse = await httpClient.GetStringAsync(string.Format("{0}{1}",BaseUrl,"socialevents/1"));
var eventArray = JsonConvert.DeserializeObject<SocialEvent[]>(jsonResponse);
foreach (var evnt in eventArray)
{
socialEvents.Add(evnt);
}
return socialEvents;
}
The problem is that I get this in my application
I'm 100% sure that images is in the right format, at least I checked the base64 string in json response. Also I tried to re-size image and many other things with layout. I wrote a converter from byte[]
to ImageSource
but there was no result too.
Any ideas guys?
P.S. Sorry for my English, I hope you understand me ;)
Aucun commentaire:
Enregistrer un commentaire