Windows Phone 使用 Listbbx 绑定列表框 [英] Windows Phone Bind Listbox With a Listbbx

查看:29
本文介绍了Windows Phone 使用 Listbbx 绑定列表框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含图像列表的类.

I have a class with a list of images in it.

    public class RSSClass
{
public string Title { get; set; }
public string Summary { get; set; }
public string PubDate { get; set; }
public List<ImageData> ImagePath { get; set; }

public class ImageData
{
    public Uri ImageLocation
    {
        get;
        set;
    }
}
}

她的 XAML

           <ListBox Name="lstRSS">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel>
                            <StackPanel.Resources>
                            </StackPanel.Resources>
                            <TextBlock Text="{Binding Path=Title}"> </TextBlock>
                            <TextBlock Text="{Binding Path=PubDate}"></TextBlock>
                            <TextBlock Text="{Binding Path=Summary}"></TextBlock>
                            <ListBox x:Name="ImageListBox" ItemsSource="{Binding ImagePath}">
                                    <DataTemplate>
                                        <Image x:Name="image1" Source="{Binding}" MaxHeight="80" MaxWidth="120" Margin="0"></Image>
                                    </DataTemplate>
                            </ListBox>
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>

内部列表框 ImageListBox 绑定并显示 Uri 的字符串值.我只是不确定将内部列表框中的图像 image1 绑定到什么?

The inner list box, ImageListBox, binds and shows the string value of the Uri. Im just not sure what to bind the image in the inner list box, image1, to?

非常感谢任何帮助.

问候罗斯

推荐答案

您的 周围缺少 .这会混淆 ListBox,因此它认为它实际上是一个项目,而不是模板.

You are missing <ListBox.ItemTemplate> around your <DataTemplate>. This confuses ListBox, so it thinks it is actualy an item, not a template.

这篇关于Windows Phone 使用 Listbbx 绑定列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆