DefaultImageSrc not works if treeview is inside usercontrol

2 posts, 1 answers
  1. Arshad
    Arshad avatar
    10 posts
    Member since:
    Apr 2016

    Posted 13 Jun 2016 Link to this post

    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..??/



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


    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..??

  2. Answer
    Martin Ivanov
    Martin Ivanov avatar
    1452 posts

    Posted 16 Jun 2016 Link to this post

    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.
    • 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.

    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top