Good Morning Valentin,
Thank you very much for your calm and reasonable reply.
I realise I am being unresonable by asking you more than I have a right to. However the more time I spend trying to work this out, the more frustrated I get - sorry!
I understand you have many other things to do, but if you could use the following to display a tree, I would be extremely grateful. (as I am sure will quite a few others)
------------------------
SCENARIO ONE
------------------------
This is a XML file I am trying to display in your tree. It is called genericXML.
<?
xml version="1.0" encoding="UTF-8"?>
<Items>
<XmlNodeItem Header="Animal">
<Items>
<XmlNodeItem Header="Dog" />
<XmlNodeItem Header="Cat" />
</Items>
</XmlNodeItem>
<XmlNodeItem Header="Fish">
<Items>
<XmlNodeItem Header="Fresh Water">
<Items>
<XmlNodeItem Header="Roach"/>
<XmlNodeItem Header="Bream"/>
</Items>
</XmlNodeItem>
<XmlNodeItem Header="Salt Water">
<Items>
<XmlNodeItem Header="Edible"/>
<XmlNodeItem Header="Flat">
<Items>
<XmlNodeItem Header="Skate"/>
<XmlNodeItem Header="Sole"/>
</Items>
</XmlNodeItem>
</Items>
</XmlNodeItem>
</Items>
</XmlNodeItem>
</Items>
Th following retrieves this XML file from the server. Could you please demonstrate how to display it using your RadTreeView.
public MyTestTree()
{
InitializeComponent();
LoadXMLFile();
}
private void LoadXMLFile()
{
WebClient xmlClient = new WebClient();
xmlClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(XMLFileLoaded);
xmlClient.DownloadStringAsync(new Uri("genericXML.xml", UriKind.RelativeOrAbsolute));
}
void XMLFileLoaded(object sender, DownloadStringCompletedEventArgs e)
{
//The content of this procedure is proably complete rubbish but I include it anyway.
if (e.Error == null)
{
string xmlData = e.Result;
XDocument xmlItems = XDocument.Parse(xmlData);
var items = from item in xmlItems.Descendants("Items")
select item;
myTree.ItemsSource = items.ToList();
}
}
------------------------
SCENARIO TWO
------------------------
The following is the contents of an SQL Server table called TreeNoText
NodeID ParentID NodeText
0 0 Cars
1 0 Notes
2 0 Big
3 2 Cadillac
4 2 Humvee
5 0 Small
6 5 Clio
7 5 Punto
8 0 Animals
9 8 Mammals
10 9 Land
11 10 Horse
12 10 Rabbit
13 12 Floppy Eared
14 9 Sea
15 14 Whale
16 8 Reptiles
17 16 Crocodile
18 16 Alligator
The following code retrieves the TreeNoText table (using ADO.NET Data Services) and displays it in a standard MS grid. It would be outstanding if you could also demonstrate how to display this in a RADTreeView.
public Page()
{
InitializeComponent();
Loaded += new RoutedEventHandler(Page_Loaded);
}
void Page_Loaded(object sender, RoutedEventArgs e)
{
Uri ServiceAddress = new Uri(Application.Current.Host.Source, "../ADONetService.svc");
Broadgate_DataEntities proxy;
proxy = new Broadgate_DataEntities(ServiceAddress);
DataServiceQuery<TreeNoText> query =
(DataServiceQuery<TreeNoText>)(from c in proxy.TreeNoText
where c.PropertyNumber == "00003"
select c);
query.BeginExecute(TreeNoTextCallback, query);
}
private void TreeNoTextCallback(IAsyncResult iar)
{
ObservableCollection<TreeNoText> listTreeNoText = new ObservableCollection<TreeNoText>();
DataServiceQuery<TreeNoText> query = (DataServiceQuery<TreeNoText>)iar.AsyncState;
IEnumerable<TreeNoText> results = query.EndExecute(iar);
listTreeNoText = new ObservableCollection<TreeNoText>();
foreach (var item in results)
{
listTreeNoText.Add(item);
}
myDataGrid.DataContext = listTreeNoText;
}
------------------------------------
------------------------------------
I will be surprised if you read as far as this but if you have, thankyou.
As I said before, I know I am asking a lot, so an answer to either one of the above scenarios would be extremely well received. An answer to both would be outstanding.
Waiting in anticipation,
Pete.