We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Can not create TreeViewItems from CodeBehind

Hi there,

I've tried to create TreeViewItems from CodeBehind. The TreeView is defined in my Xaml without any Items.

This is what I've tried:

private void CreateTree()
{
Global anlegen
TreeViewItemAdv globalItem = new TreeViewItemAdv()
{
Header = "Global",
Tag = "global",
IsExpanded = true
};
TreeViewItemAdv paraZuordnenItem = new TreeViewItemAdv()
{
Header = "Parametergruppen zuordnen",
Tag = "parametergruppen zuordnen"
};
TreeViewItemAdv paraDefItem = new TreeViewItemAdv()
{
Header = "Parameter definieren",
Tag = "parameter definieren"
};
treeViewAdv1.Items.Add(globalItem);
globalItem.Items.Add(paraZuordnenItem);
globalItem.Items.Add(paraDefItem);

}


The method is called after InitialisingComponent and runs through without any Errors. But after all I get this message:

The object reference was not specified on an object instance.


What am I doing wrong?


1 Reply

DM Deenadhayalan M Syncfusion Team February 21, 2011 12:19 PM UTC

Hi Andreas,

Thanks for using our Syncfusion products.

We create a sample with TreeViewAdv as you told. And we are not able to reproduce the issue from our side. We have attached the sample for reference. Please provide us some more information to reproduce the issue so that we can provide the solution at earliest.

Regards,
Deenadhayalan M



TreeView_d3ab2b65.zip

Loader.
Live Chat Icon For mobile
Up arrow icon