views:

395

answers:

1

I have a RadTreeView (Telerik's version of a TreeView) that has the following hierarchical order:

<navigation:RadTreeView ImagesBaseDir="/Images/" x:Name="rtvLibrary" Margin="8" Grid.Row="0">
            <navigation:RadTreeViewItem DefaultImageSrc="Home.png" Header="Home" IsExpanded="True">
                <navigation:RadTreeViewItem DefaultImageSrc="Todo.png" Header="Tasks" />
                <navigation:RadTreeViewItem DefaultImageSrc="Flag.png" Header="Flagged" />
                <navigation:RadTreeViewItem DefaultImageSrc="Completed.png" Header="Completed" />
                <navigation:RadTreeViewItem DefaultImageSrc="Courses.png" Header="Courses">
                    <navigation:RadTreeViewItem DefaultImageSrc="Folder.png" Header="Winter 2010">
                        <navigation:RadTreeViewItem DefaultImageSrc="Course.png" Header="Health" />
                    </navigation:RadTreeViewItem>
                </navigation:RadTreeViewItem>
            </navigation:RadTreeViewItem>
        </navigation:RadTreeView>

And inside the RadTreeViewItem with the Header of Courses, I will allow users to make many folders and courses (RadTreeViewItems). So how can I iterate though all the RadTreeViewItems within the RadTreeViewItem with the Header of Courses?

+1  A: 

So how can I iterate though all the RadTreeViewItems

Don't do it this way ; bind your TreeView to a collection instead. That way you won't have to manipulate UI components to access the data, you will access the data directly. By keeping a good separation of UI and data, your code will be much easier to maintain, to test and to reuse

Thomas Levesque
Like in an XML file?
Mohit Deshpande
I don't understand what you mean... this has nothing to do with XML (although you *could* bind directly to XML data if it makes sense for you)
Thomas Levesque
I don't really understand what you mean, too. (for the answer, not the comment)
Mohit Deshpande
I don't know how to explain it better... Have a look at the MVVM pattern, it should help you to understand. http://msdn.microsoft.com/en-us/magazine/dd419663.aspx
Thomas Levesque