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

Hierarchical Data Template images - some missing when xaml files grouped into folders

7 Answers 127 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 31 Jul 2009, 08:27 PM
Today I moved my File.xaml from the project root to a folder hierarchy - xaml\folder1\File.xml.  The following Hierarchical Data Template stopped working.  Specifically, X continues to work and find the right image, but Y and Z don't display their images any longer.  I could accept if they all lost their images, but why only the 2nd and 3rd level templates?

<DataTemplate x:Key="ZTemplate"
  <StackPanel Orientation="Horizontal"
    <Image Margin="2,0,2,0"  Source="images/tree/z.png"/> 
    <TextBlock Text="{Binding z}" /> 
  </StackPanel> 
</DataTemplate> 
 
<Controls:HierarchicalDataTemplate x:Key="YTemplate" 
  ItemTemplate="{StaticResource ZTemplate}"
  <StackPanel Orientation="Horizontal"
    <Image Margin="2,0,2,0" Source="images/tree/y.png"/> 
    <TextBlock Text="{Binding y}" /> 
  </StackPanel> 
</Controls:HierarchicalDataTemplate> 
<Controls:HierarchicalDataTemplate x:Key="XTemplate"  
  ItemTemplate="{StaticResource YTemplate}"
  <StackPanel Orientation="Horizontal"
    <Image Margin="2,0,2,0"  Source="images/tree/x.png"/> 
    <TextBlock Text="{Binding x}" /> 
  </StackPanel> 
</Controls:HierarchicalDataTemplate> 
 

<Telerik:RadTreeView ... 
  ItemTemplate="{StaticResource XTemplate}"  
  ExpanderStyle="{StaticResource LoadOnDemandExpanderStyle}" 
  LoadOnDemandEnabled="True" /> 
 
 

What is the proper way to reference image paths if I want to group xaml files togther by function?

I using v2.0.50727 / 2009.2.720.1020 after my last reported problems.

Thanks,
Tim

7 Answers, 1 is accepted

Sort by
0
Tim
Top achievements
Rank 1
answered on 04 Aug 2009, 12:00 AM
Anyone have an insight on this?  Should I open a support ticket?  I started refactoring my project but have stopped awaiting the answer to my question.

Thanks,
Tim

0
Tim
Top achievements
Rank 1
answered on 05 Aug 2009, 12:28 AM
I can further confirm that:

  • All my images show up in my .dll as resources, following the proper path (images/tree/x.png, images/tree/y.png, images/tree/z.png)
  • For the ones which are not found, the IIS log shows a 404 error with the nested xaml path in between the images/tree/z.png and the base (ClientBin), i.e.:

2009-08-04 23:50:06 W3SVC1 GET /virtualdir/ClientBin/xaml/Package/SubPackage/images/tree/y.png - 80 myusername 404

Tim
0
Ivan
Telerik team
answered on 06 Aug 2009, 08:16 AM
Hello Tim,

Thank you for sending us the example code. It really helps us to find and correct the problem.

Because the YTemplate and the ZTemplate templates have not been referred in the hierarchical template chain - this is the reason of missing pictures. Even more your tree object refers a "xTemplate" while your code defines the "XTemplate". All this small beans are the reason for nonworking example.

Attached you can find an example with a corrected version of your code. Please give it a try and let us know if there are more questions.

Regards,
Ivan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Accepted
Ivan
Telerik team
answered on 06 Aug 2009, 09:21 AM
Hi Tim,

I am writing back because I have forgot to modify the application regarding its folder restructuring. Please excuse me.

Below is the explanation of what I have fixed in order to run your case:
  • Move the code related to the tree into xaml\folder1\MyFiles.xaml file.
  • In order to demonstrate some different techniques I have tuned a bit the images up: Source in Templates as:
    • The Build Action of picture files:
      •  Z.png and Y.png files are initialized with Resource Build Action.
      •  X.png file is initialized with Content Build Action.
    • The images' Source in Templates:
      • Accessing resources with a relative or absolute path as:
        Source="../../images/tree/z.png"
        Source="/AgApp;Component/images/tree/y.png"
      • Accessing a picture file built as content:
        Source="/images/tree/x.png"
  • Build and run the application.

Attached you can find the modified example.

Regards,
Ivan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Tim
Top achievements
Rank 1
answered on 06 Aug 2009, 11:26 AM
Ivan,

The chain is right - I tried to keep the example trivial and remove the parts that didn't concern the issue - my bad in copy-and-pasting-and-editing it.  I fixed the original post.  Thanks for your example, I will try it out.

Tim
0
Tim
Top achievements
Rank 1
answered on 06 Aug 2009, 04:58 PM
OK, I got it to work by the absolute path including the xap -  /MyXap;Component/images/tree/x.png.  Thanks.  It still seems wrong, but I've been in the web business for 12+ years and my view of URLs is more standards-oriented than Microsoft's.  Oh, and your example is only SL3 so I couldn't actually run it.

Tim

0
Ivan
Telerik team
answered on 10 Aug 2009, 06:26 PM
Hello Tim,

Please find attached the Silverlight-2 version of the example.

PS: When we are talking about image visualization in Silverlight its a good starting point to preview the Different ways for loading images and files in Silverlight 2 applications article.


Greetings,
Ivan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
TreeView
Asked by
Tim
Top achievements
Rank 1
Answers by
Tim
Top achievements
Rank 1
Ivan
Telerik team
Share this question
or