English 中文(简体)
从 JSON 获取图像 URL 绑定到列表框
原标题:Get Image URL to Listbox Binding from JSON

我有JSON的要求 抢走URI 甚至可以把物品装订起来 但不是图像

XAML: 时间轴:

 <Image delay:LowProfileImageLoader.UriSource="{Binding ImageUrl}" Width="120" Height="120" />
 <TextBlock Text="{Binding DisplayName}" FontSize="30" TextWrapping="Wrap" TextTrimming="WordEllipsis" />

现在,一旦我得到了饲料,我运行它如此:

    using (var stream = new MemoryStream(Encoding.Unicode.GetBytes(e.Result)))
        {
            DataContractJsonSerializer dataContractJsonSerializer = new DataContractJsonSerializer(typeof(ProviderChannels.RootObject));
            var providerResult = (ProviderChannels.RootObject)dataContractJsonSerializer.ReadObject(stream);


            if (providerResult.ServiceDetailsResult != null)
            {

                ProviderChannels.ItemsSource = providerResult.ServiceResult.Lineup.Channels;

            }

问题是,我无法从图像Url中获取图像:

    public class Channeli
    {
        public string DisplayName { get; set; }
        public List<object> ChannelImages { get; set; }

    }

摄像/频道图像 这样做:

    "ChannelImages": [
                    {
                        "ImageUrl": "http://the-url-generated.com/file.png",
                        "ImageUseType": null,
                    }

Channelimages报告了一个图像Url 和一堆其他数据, 但我需要严格的图像Url, 但如果我把图像Url放入 XAML, 它不会工作, 但如何使用频道图像获取图像Url?

谢谢你的帮助!

问题回答

您应该以图像URL的形式转发字符串, 而不是像您现在所做的一样列出对象 。

对于所有适合使用你现在的代码的事物, 你的 通道 < / em> 类应该看起来是这样的:

 public class Channels
 {
     public string DisplayName { get; set; }
     public string ImageUrl { get; set; } 
 }




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...