How to add rows to gridview dynamically in windows phone?

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

Was this solution helpful to you?

Just Added Q & A:

Find solution

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.