I recently wrote an app targeting WP 7.1 SDK which uses a ListBox and DataBinds it from code behind. When I run this app on a WP8 device or a WP8 emulator, the app works fine and I can see the data on the page. But when this exact same app is run on a WP7.5 device or emulator, the ListBox does not show any data. I have not been able to figure out why for the life of me!
Here is the ListBox in XAML:
The ListBox is data bound from code behind by doing this:Code:<ListBox Name="lbCurrentTickets" SelectionChanged="lbCurrentTickets_SelectionChanged" Margin="10,10,0,0"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text="{Binding Path=StartDate}" Margin="0,15,0,0" FontWeight="ExtraBold" Foreground="Black" /> <TextBlock Text="{Binding Path=Title}" Margin="0,-5,0,0" FontSize="30" Foreground="#3A87D3" /> <TextBlock Text="{Binding Path=Address}" Margin="0,-5,0,0" FontSize="22" Foreground="Gray" Visibility="{Binding ShowAddressField}" /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox>
'events' is an object of a class, and I have verified that it does contain all the right data at this point. When this code is run on a WP7.5 device the ListBox shows up empty even though it is bound with actual data, but when this exact code is run on a WP8 device it shows the data perfectly fine.Code:lbCurrentTickets.ItemsSource = events;
Just for testing sake I hardcoded one of the TextBlocks inside the ListBox with a value, like:
and the text "This is a test" shows up the right number of times (the number of items in the 'events' object) which means the ListBox is being data bound somewhat properly.Code:<TextBlock Text="This is a test" Margin="0,-5,0,0" FontSize="30" Foreground="#3A87D3" />
Can someone help resolve this issue as to why the ListBox displays empty when I run this code on a WP7.5 device?
To summarize, this WP7.1 app works fine on a WP8 device but not on a WP7.5 device.
Regards,
Paras Wadehra
My WP Apps: http://bit.ly/MyWPApps

Reply With Quote

