我的 Windows Phone 应用程序有问题。当我从 Web 服务获取照片时,我想将其显示为页面上的图像。Web 服务返回一个 byte[] 作为图像数据。
Dispatcher.BeginInvoke(() =>
{
    tempImage = new BitmapImage();
    globalWrapper = (PhotoWrapper)JsonConvert.DeserializeObject(
                                      response.Content, typeof(PhotoWrapper));
    tempImage.SetSource(new MemoryStream(globalWrapper.PictureBinary, 0,
                                         globalWrapper.PictureBinary.Length));
    globalWrapper.ImageSource = tempImage;
    PictureList.Items.Add(globalWrapper);
});
PictureList 是一个 ListBox 定义为:
<ListBox Name="PictureList" ItemsSource="{Binding}" Margin="0,0,0,0">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <StackPanel>
                <Button Click="details_Click">
                    <Button.Content>
                        <Image Source="{Binding ImageSource}"></Image>
                    </Button.Content>
                 </Button>
            </StackPanel>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>
现在,我的问题是,您如何从 web 服务接收一个 byte[] 作为 JSON 并将其显示在页面上?我觉得我在这里很近,但缺少一些相当基本的东西。