How can I add a Icon to a tree view item:
I am using this code to add the nodes:
newNode = new Infragistics.Silverlight.Controls.XamWebTreeItem(); newNode.Header = location.LocationName; newNode.Name = location.LocationID.ToString(); treeNode.Items.Add(newNode);
newNode = new Infragistics.Silverlight.Controls.XamWebTreeItem();
newNode.Header = location.LocationName;
newNode.Name = location.LocationID.ToString();
treeNode.Items.Add(newNode);
as you can see I am adding the nodes programmatically, and I need to put a icon in the items.
Thanks in advance...
Hi,
You can use the ExpandedIcon and CollapsedIcon properties of the XamWebTreeItem to specify an icon next to the node.
Hope this helps.
-SteveZ
Everytime I try this I get a error "item does not fall between the expected range" or something like that...
I created a BimapImage resource in the control where I use the webtree and by code add this image to the ExpandedIcon... but that does not work...
Sounds like you're using the same image for each node. This is going to cause an exception, b/c you can only have one instance of an image in the visual tree at any given time. Thus the exception.
Try using a DataTemplate instead with an Image in it. Then load the DataTemplate from a Resource, and call LoadContent on the DataTemplate, each time you set the ExpandIcon property.