WP7中的列表框绑定不显示数据, [英] Listbox Binding in WP7 doesnt display the data,

查看:104
本文介绍了WP7中的列表框绑定不显示数据,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想将列表框绑定到列表,这是列表框的xaml代码:

Hi,

I want to bind a list box to a List, and here is my xaml code of the listbox:

<ListBox Name="RoutineList" Tap="RoutineList_Tap">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Vertical">
                                    <TextBlock Name="routineName" Text="{Binding RoutineName}" FontSize="24"/>
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Text="Total Duration: " Style="{StaticResource PhoneTextNormalStyle}"/>
                                        <TextBlock Name="totalDuration" Text="{Binding TotalDuration}"/>
                                    </StackPanel>
                                </StackPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>




和我用来绑定数据源的代码:




and the code i used this to bind the data source:

this.RoutineList.ItemsSource = routineList;



例程列表的类型为List<routine></routine>,并且Routine类具有字符串类型的RoutineName和int类型的TotalDuration以及其他一些属性,

AFAIK,这应该可以在SL/WPF中使用,但是当我尝试在模拟器中运行它时,它仅显示在xaml中定义的总持续时间",没有RoutinName或TotalDuration的值,但是列表框中的项目数等于列表中的项目数,我在哪里做错了?



the routineList is of type List<routine></routine>, and the Routine class have a property of RoutineName of type string, and TotalDuration of type int, and some other properties,

AFAIK, this should work in SL/WPF, but when i try to run this in the emulator, it only display the "Total Duration" which is defined in the xaml, without the value of the RoutinName or TotalDuration, but the number of the items in the listbox is equal to the number of items in the List, where did i do wrong?

推荐答案

我看到总持续时间" TextBlock具有特定的样式.尝试为其他TextBlock设置这种样式.

As I see the "Total Duration" TextBlock has a specific style. Try to set this style also for the other TextBlocks.


好像我犯了一个非常愚蠢的错误,
我没有放置属性的访问器,
解决了,为这个问题感到抱歉.
seems like i did a pretty stupid mistake,
i didn''t put the accessor for the properties,
solved, sorry for the problem.


这篇关于WP7中的列表框绑定不显示数据,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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