首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将ListBox绑定到listBox WP8中

将ListBox绑定到listBox WP8中
EN

Stack Overflow用户
提问于 2015-01-15 06:36:14
回答 1查看 139关注 0票数 0

我需要用下面的类结构将名为cityListBox的列表框绑定到ContryListBox中

代码语言:javascript
复制
public class Country
{
    public Country();

    public string ID { get; set; }

    public List<City> LstCity { get; set; }

    public string Title { get; set; }
}

我希望我的外部列表框应该附带国家标题作为标题,在innner listbox城市标题中,城市也是一个具有Id和标题的类

我的xaml代码:

代码语言:javascript
复制
       <ListBox x:Name="ContryListBox">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel>

                        <Bewise:ExpanderControl HeaderText="{Binding Title, Mode=OneWay}" >
                            <Bewise:ExpanderControl.ContentArea>


                                <ListBox x:Name="cityListBox " >
                                    <ListBox.ItemTemplate>
                                        <DataTemplate>
                                            <StackPanel>
                                                <CheckBox></CheckBox>
                                                <TextBlock Text="{Binding Title}"/>
                                            </StackPanel>

                                        </DataTemplate>
                                    </ListBox.ItemTemplate>
                                </ListBox>


                            </Bewise:ExpanderControl.ContentArea>

                        </Bewise:ExpanderControl>


                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-01-15 06:55:51

代码语言:javascript
复制
<!--Added ItemsSource binding-->
<ListBox x:Name="ContryListBox" ItemsSource="{Binding YourCountryListProperty}>
        <ListBox.ItemTemplate>
            <DataTemplate>
                <StackPanel>
                    <Bewise:ExpanderControl HeaderText="{Binding Title, Mode=OneWay}" >
                        <Bewise:ExpanderControl.ContentArea>
                            <!--Added ItemsSource Binding-->
                            <ListBox x:Name="cityListBox" ItemsSource="{Binding LstCity}">
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <StackPanel>
                                            <CheckBox></CheckBox>
                                            <TextBlock Text="{Binding Title}"/>
                                        </StackPanel>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>
                        </Bewise:ExpanderControl.ContentArea>
                    </Bewise:ExpanderControl>
                </StackPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27957959

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档