Radtreeview self referencing

10 posts, 0 answers
  1. macky
    macky avatar
    11 posts
    Member since:
    May 2009

    Posted 26 Apr 2011 Link to this post

    Hi Telerik Staff,

             I just copy the codes using C#  and it doesn't compile. And I copied it on your  help website : http://www.telerik.com/help/wpf/radtreeview-how-to-bind-to-self-referencing-data.html.

           Please send me  a project  on this.  I hope you will send a zip file for me.

    Thanks,
    Mac
  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 28 Apr 2011 Link to this post

    Hello macky,

     I see that you've opened a forum thread for RadTreeView for Silverlight but you have pasted a link from WPF documentation. Here is the SL`s documentation link. I can thought of at least one difference in the code snippets ( HierarchicalDatatemplate in WPF ==> telerik:HierarchicalDataTemplate in SL). Let us know if this helps you.s

    Greetings,
    Petar Mladenov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. Vincent
    Vincent avatar
    34 posts
    Member since:
    Apr 2011

    Posted 14 May 2011 Link to this post

    Hi!! Do you have a complete code for this?? When I copy the code.. they have errors.... thanks... :)
  5. Vincent
    Vincent avatar
    34 posts
    Member since:
    Apr 2011

    Posted 14 May 2011 Link to this post

    it says that local hierarchyconverter does not exist... 
  6. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 18 May 2011 Link to this post

    Hi Vincent,

    Probably because your converter class has not been build successfully, have you added System.Linq namespace necessary for the "Where" extension methods? I am attaching a working example created by following the help article. Let us know if this helped you.

    Best wishes,
    Petar Mladenov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Vincent
    Vincent avatar
    34 posts
    Member since:
    Apr 2011

    Posted 18 May 2011 Link to this post

    Thanks Telerik! I got it now!
  8. Vincent
    Vincent avatar
    34 posts
    Member since:
    Apr 2011

    Posted 20 May 2011 Link to this post

    HI! Thank you! I know now the correct code...
    But I have some concern.. in your textblock, when I select an item from the treeview, it binds the value. Do you know how to bind the ITEM ID and the Parent ID when I select an item in the treeview?
  9. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 20 May 2011 Link to this post

    Hello Vincent,

    You can do something like so;
    <Grid.Resources>
             <local:HierarchyConverter x:Key="HierarchyConverter" />
             <telerik:HierarchicalDataTemplate x:Key="ItemTemplate" 
                                               ItemsSource="{Binding Converter={StaticResource HierarchyConverter}}">
                 <StackPanel Orientation="Horizontal">
                     <TextBlock Text="{Binding Text}" />
                     <Rectangle Fill="DeepSkyBlue" Height="18" VerticalAlignment="Center" Width="2" />
                     <TextBlock Text="parent ID: " Foreground="Blue"/>
                     <TextBlock Text="{Binding ParentId}" />
                     <Rectangle Fill="DeepSkyBlue" Height="18" VerticalAlignment="Center" Width="2" />
                     <TextBlock Text="Id: " Foreground="Blue" />
                     <TextBlock Text="{Binding Id}" />
                 </StackPanel>
             </telerik:HierarchicalDataTemplate>
         </Grid.Resources>
    Please let us know if this is what you need.

    Best wishes,
    Petar Mladenov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  10. Angeli
    Angeli avatar
    29 posts
    Member since:
    Apr 2011

    Posted 28 May 2011 Link to this post

    Hi Petar. How do I update the Text as well as the Parent ID when I add/remove/edit an item through a RadContextMenu?
  11. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 01 Jun 2011 Link to this post

    Hi Angeli,

    You first have to access the RadTreeViewItem  clicked with the mouse right button when the ContextMenuOpens:
    private void ContextMenuOpened(object sender, RoutedEventArgs e)
            {
                RadTreeViewItem treeViewItem = (sender as RadContextMenu).GetClickedElement<RadTreeViewItem>();
    You can see this realized in this demo. Then you probably need a twoway binding to a ViewModel ( if you want the visual changes to reflect the data behind). Let us know if you need further assistance on this.

    Kind regards,
    Petar Mladenov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top
DevCraft banner