I'm returning from a class an XML string (returned from a stored procedure into a CSLA object):
<
Tree
>
<
Node
Value
=
"4641"
Text
=
"Test Parent Node 1"
Expanded
=
"true"
/>
<
Node
Value
=
"1234"
Text
=
"Test Child Node 1"
Expanded
=
"true"
/>
</
Node
>
</
Tree
>
in .Net, you could simply do a TreeView.LoadXml(xmlString).
How do you do the equivalent in Silverlight?
Can anyone help? The example say to deserialize from a reader, etc. But I can't get it to work...can anyone point me in the right direction???
Thanks!
V
12 Answers, 1 is accepted
I think this article is what you are looking for. I've also sent you a sample project, so could you please examine it and if you have further questions feel free to ask?
Kind regards,Starting from this example how can I add a node to treview?
I've updated the previous project to demonstrate adding a new items to the TreeView as well as saving the newly created structure to the IsolatedStorage.
Please take a look at the attached project and let me know how it works for you.
Greetings,
Kiril Stanoev
the Telerik team
Luciano
i need to expand the Particular Node Programatically. I will be sending a particular Node Header text Programatically . i need to expand that Node's.
as per example
- >ANIMAL - Dog
like Fish|Fresh Water|roach
similiar to this example --
rad.SelectItemByPath(
"Fish|Fresh Water|roach");
rad.PathSeparator =
"|";
rad.ExpandItemByPath(iop);
So that i can expand the node's programatically.
can u plz make it asap....
Looking for ur reply,
bala s
can u plz help me with this .....
i m already working with treeview as source as sql db. Since i m finding a delay in binding process. i m planning to move to XML binding.
But i m unnable to programatically expand its Node.which i m able to do in normal radtree view. Similirlly like this
Ex:
rad.SelectItemByPath(
"Fish|Fresh Water");
rad.PathSeparator =
"|";
rad.ExpandItemByPath(iop);
but i m uable to expand the Node. could u Plz guide me with this.
Looking for ur response at the earliest,
Bala s
Could you take a look at the following code segments and give them a try (I'm using the treeviewxmlbinding.zip attached project).
<
telerik:RadTreeView
x:Name
=
"thetree"
ItemTemplate
=
"{StaticResource Item}"
Loaded
=
"RadTreeView_Loaded"
ItemsSource
=
"{Binding Source={StaticResource treeViewData}}"
telerik:TextSearch.TextPath
=
"Header"
/>
private
void
RadTreeView_Loaded(
object
sender, RoutedEventArgs e)
{
this
.thetree.BringPathIntoView(@
"Fish\Fresh Water\Roach"
);
}
There are two important steps:
1) Set the TextPath attached property in xaml (use the telerik schema).
2) Call the BringPathIntoView method with the correct path.
Hope this helps.
Regards,
Hristo
the Telerik team
i m following only the same treeviewxmlbinding.zip sample. And i included
<
Grid.Resources>
<local:RadTreeViewXmlDataSource x:Key="treeViewData" Source="SampleXML.xml" />
<telerik:HierarchicalDataTemplate x:Key="Item" ItemsSource="{Binding Items}" telerik:TextSearch.TextPath="Header">
<TextBlock Text="{Binding Header}" />
</telerik:HierarchicalDataTemplate>
</Grid.Resources>
<telerik:RadTreeView Name="rad" ItemTemplate="{StaticResource Item}"
ItemsSource="{Binding Source={StaticResource treeViewData}}" Selected="rad_Selected" telerik:TextSearch.TextPath
=
"Header"
/>
</Grid>
but i'm unable to Expand nodesusing -
this
.rad.BringPathIntoView(@
"Fish\Fresh Water\Roach"
);
could u plz reply ... me.
extremly Sorry for the Reply to the post. i'm able get it .I m able to expand Nodes Now. I got the Issue cleared. and If U don't mind.
could u plz describe me regarding the Search Method To search for a node in Treeview for a particular node using Search option from a Textcolumn?
thks for ur kind help
Could you please elaborate more on your sceanario, what do you exactly mean with "Method To search for a node in Treeview for a particular node using Search option from a Textcolumn "? Could you please check out the following article and let us know if it satisfies you? Basically it shows how to iterate over the RadTreeViewItems. In databinding scenarios, you may need to traverse the ViewModel hierarchy and the get the corresponding RadTreeViewItem by invoking the GetItemByPath() method.
All the best,Petar Mladenov
the Telerik team
thanks for ur previous posts. i need now to highlight the text that i search for . So that i can show the text highlighted that i search for . and i need it for both binding methods.(treeview binding using database & treeview binding using XML Methods).
looking for ur Highlighted Post,
Bala s
Let's suppose you have found a ViewModel after you have traversed the ViewModel hierarchy. Then you can get the RadTreeViewItem (the visual container for the ViewModel/objecy) with the method RadTreeView.ContainerFromItemRecursive(object item). Once you have the RadTreeViewitem, its Header property will return the Panel/Control used in the DataTempalte that is set as an ItemTemplate of the RadTreeView.
In other words if you have:
<
DataTemplate
x:key
=
"itemtemplate"
>
<
TextBlock
Text
=
"{Binding Name}"
/>
</
DataTemplate
>
<
DataTemplate
x:key
=
"itemtemplate"
>
<
Grid
>
<
TextBlock
Text
=
"{Binding Name}"
/>
</
Grid
>
</
DataTemplate
>
Hope this helps you.
Kind regards,
Petar Mladenov
the Telerik team