This is a migrated thread and some comments may be shown as answers.

DefaultImageSrc not works if treeview is inside usercontrol

1 Answer 83 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Arshad
Top achievements
Rank 1
Arshad asked on 14 Jun 2016, 04:27 AM

I am having a treeview in a usercontrol and am trying to bind the node image .But it only works if i gave the entire full path of the image. Finally i found out if a treeview is inside an usercontrol relative paths wont work. So how can i assign am image to a node which was inside the user control..??/

 

DefaultImageSrc="/MyOtherProject;component/Images/File.png".

the above will work for usercontrol they have mentioned. Can it be explained ..? whats MyOtherProject,component etc.

Note:

My usercontrol was in the same project in which i work.My solution name is TreeView_WPF_Customized and the image was inside the Resources  folder.

How to display the image my scenario..??

1 Answer, 1 is accepted

Sort by
0
Accepted
Martin Ivanov
Telerik team
answered on 16 Jun 2016, 09:31 AM
Hello Arshad,

Indeed, the relative path doesn't work in a scenario where the treeview is wrapped into a user control, but only if this user control is defined into another project, different then the one where it is used. In this case you can use the syntax mentioned in your reply. So let me try to explain what are the main components of this relative pack URI.
DefaultImageSrc="/MyOtherProject;component/Images/File.png".
  • MyOtherProject - This is the name of the assembly where the file is stored. By default Visual Studio sets the assembly name of the project the same as the project name. So for example, if the project where the file is placed is called "WpfApplication1", the assembly name will also be "WpfApplication1". In this case, the path will be "/WpfApplication1;component/Images/File.png".
  • componont - This is a keyword which specifies that the assembly that is referred ("MyOtherProject") is referenced from the local assembly.
  • /Images/File.png - The rest of the URI is the path to the file.

So this specific path tells the following: Get me the "MyOtherProject" assembly which is referenced from the local assembly, and in its root project folder there should be a folder called "Images" which contains a file called "File.png".

I hope this information helps.

Regards,
Martin
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
TreeView
Asked by
Arshad
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or