About data binding of treelistView.

5 posts, 0 answers
  1. Neil Chow
    Neil Chow avatar
    4 posts
    Member since:
    Dec 2009

    Posted 02 Nov 2011 Link to this post

    http://www.telerik.com/help/silverlight/radtreeliestview-getting-started.html

    I don't know why, but this example doesn't work, no error, no data show.
    Is there some trick to run this sample?

    Best regards

    _Sam
  2. XamlFish
    XamlFish avatar
    2 posts
    Member since:
    Jun 2013

    Posted 05 Jun 2013 Link to this post

    Hi there,
    This is a pretty old post and has no response.  But the Getting Started example for the RadTreeListView STILL doesn't work.  I just copied it into a VS 2012 with the latest RadControls and it completely fails silently.  No errors, no data, as my fellow poster says.  Now, I'm new to binding and Silverlight, but I do know how to type....Can someone please help?  Is the problem that there is no instance of the source or DataContext?

    Also, this isn't the only time that I've run into problems like this with Telerik documentation.  If you guys are looking for help along those lines, I'm available for hire!  :-)

    Best,
    Betty

    Issue:  RadTreeListView Getting Started Example Doesn't work - http://www.telerik.com/help/silverlight/radtreeliestview-getting-started.html
  3. DevCraft banner
  4. Yoan
    Admin
    Yoan avatar
    1068 posts

    Posted 06 Jun 2013 Link to this post

    Hello Betty,

    I have prepared a sample project based on the mentioned help article and everything works as expected. Please find it attached. 


    Regards,
    Yoan
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  5. XamlFish
    XamlFish avatar
    2 posts
    Member since:
    Jun 2013

    Posted 06 Jun 2013 Link to this post

    Thanks for the quick response back!  Once piece I was missing was the ItemSource statement in the Mainpage.cs.  However, the Items collection isn't displaying and I can't figure out what's missing.  Can you help?  See the attached picture.

    Thanks.
  6. Yoan
    Admin
    Yoan avatar
    1068 posts

    Posted 10 Jun 2013 Link to this post

    Hello Betty,

    By default the RadTreeListView will auto-generate the columns for your data, by creating a column for each property. In order to prevent this you have to set the AutogenerateColumns property to False and to manually add the desired columns to the Columns collection of the control. Please check the following code snippet for a reference:

    <telerik:RadTreeListView x:Name="radTreeListView"
                             AutoGenerateColumns="False">
             <telerik:RadTreeListView.ChildTableDefinitions>
                 <telerik:TreeListViewTableDefinition ItemsSource="{Binding Items}" />
             </telerik:RadTreeListView.ChildTableDefinitions>
             <telerik:RadTreeListView.Columns>
                 <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"
                                     Header="Name" />
                 <telerik:GridViewDataColumn DataMemberBinding="{Binding Count}"
                                     Header="Count" />
             </telerik:RadTreeListView.Columns>
         </telerik:RadTreeListView>

    Please give it a try and let me know how it goes.


    Regards,
    Yoan
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
DevCraft banner