Click here to Skip to main content
15,918,343 members
Please Sign up or sign in to vote.
0.00/5 (No votes)

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">
                                <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}"/>

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

this.RoutineList.ItemsSource = routineList;

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?
Updated 6-Nov-11 22:57pm

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

Share this answer
BlackJack99 7-Nov-11 4:42am    
actually they originally had that style, i removed some of them on a futile attempt to fix the issue,
but anyway, tried applying the style to all of them, and remove the style from all of them as well, still not fixed..
seems like i did a pretty stupid mistake,
i didn't put the accessor for the properties,
solved, sorry for the problem.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900