9

I am adding image to the radtreeviewitem from resources programatically using the below code.

"/myAssembley;component/Resources/image1.png"

and the image is displaying successfully. Now i need to add another image which needs to be displayed next to the first image in the radtreeviewitem.

how to achieve it.?

Like the below image i need my treeviewitem to display a folder icon and a red square icon in a single treeview item.

enter image description here

Dah Sra
  • 4,107
  • 3
  • 30
  • 69

2 Answers2

4

If you do not have data binding and you are using RadTreeViewItems directly you can add the additional image in the Header of the item. For example:

var stackPanel = new StackPanel() { Orientation = System.Windows.Controls.Orientation.Horizontal };
var image1 = new Image() { Source = image1Path };
var image2 = new Image() { Source = image2Path };
var textBlock = new TextBlock() { Text = itemHeader };
stackPanel.Children.Add(image1);
stackPanel.Children.Add(image2);
stackPanel.Children.Add(textBlock);

var treeViewItem = new RadTreeViewItem()
{
    Header = stackPanel,
};

It Works.

Dah Sra
  • 4,107
  • 3
  • 30
  • 69
2

The proper way would be to create a DataTemplate with a grid or horizontal stackpanel. Put two images inside and in your model two Image Sources that you can bind too. Telerik doesn't have the best track record using the MVVM pattern, but the TreeView control is pretty decent with binding. If you need help with the model and the datatemplate, post some of your code here and we can work on it.

Kevin B Burns
  • 1,032
  • 9
  • 24