Longlistselector not working when dynamically add items in list in windows phone?
-
hi guys, am working on windows phone application development , after long search in net I found how to add items manually in "LongListSelector" , but added items not visible in list . Take a look , my Longlistselector object is "Product_Source ", my Longlistselector name in xaml is longlist. whenever I adding a item , I getting longlist.Product_source is displaying but actually product name that is given in textbox is not displaying ... something am missing in code .. Please let me know , what is my problem ? Thanks in Advance
-
Answer:
Hi, I was recently facing almost the same problem too, and I think your problem is in the data binding. You just populated the objects to the control without representing variable from the related class where you declared your object. This could lead to improper data binding, and can cause the LongListSelector to display the object name instead of the object content. For the example, you can take a look at your data context that you have created. In this case, I have this class in C#: public class Product { public string productCode { get; set; } public string productName { get; set; } } In the corresponding page that you have created the LongListSelector control, you can implement the data binding in this way (control and object name are referred as above) longlist.ItemsSource(Product_source); In the XAML, make sure that the control is implementing the data binding. This can be done by going to the LongListSelector's ItemTemplate property and add the following code with variable name that you want to display in the control. <toolkit:LongListSelector.ItemTemplate> <DataTemplate> <StackPanel Orientation="Vertical"> <TextBlock Text="{Binding ProductName}"/> </StackPanel> </DataTemplate> ......... </toolkit:LongListSelector.ItemTemplate> Ok, that's all. Hope that helps! :) Please let me know if the problem still persists. Cheers
Theodorus Y. Mahendraputra at Quora Visit the source
Related Q & A:
- How to do HttpWebRequests from a Windows Phone 7?Best solution by stackoverflow.com
- How to parse single xml node in windows phone?Best solution by Stack Overflow
- Why can't I add items to the database?Best solution by Stack Overflow
- How to properly reference a user control and dynamically add it to page?Best solution by Stack Overflow
- Will Yahoo improve to allow list members to pick a new owner, when an owner leaves the list?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.