I've been working on a project based off of this example: http://www.telerik.com/help/wpf/radtreeview-how-to-wpf-windowsexplorer-like-treeview.html
Everything works except the icons don't show up. So for example, my ItemStyle for objects of type File is
I can tell the style is being set, because if I change the foreground color in the style, it affects the colors of the fonts. Only the image is not showing up.
If I instead add an <Image> to the DataTemplate like this:
Then the icons show up no problem. So any clues about what am I doing wrong? Why doesn't the DefaultImageSrc work for me in the Style? The paths are the same in both cases so its not a problem of the icon. I've tried fiddling with thigns and nothing seems to make the DefaultImageSrc work.
FYI I'm using RadControls for WPF Q1 2013 ( v.2013.1.403.40)
Thanks!
Everything works except the icons don't show up. So for example, my ItemStyle for objects of type File is
<
Style
x:Key
=
"FileItemStyle"
TargetType
=
"{x:Type telerik:RadTreeViewItem}"
>
<
Setter
Property
=
"Foreground"
Value
=
"Black"
/>
<
Setter
Property
=
"FontStyle"
Value
=
"Normal"
/>
<
Setter
Property
=
"DefaultImageSrc"
Value
=
"/Images/file.jpg"
/>
</
Style
>
I can tell the style is being set, because if I change the foreground color in the style, it affects the colors of the fonts. Only the image is not showing up.
If I instead add an <Image> to the DataTemplate like this:
<
DataTemplate
DataType
=
"{x:Type local:File}"
>
<
StackPanel
Orientation
=
"Horizontal"
>
<
Image
Source
=
"/Images/file.png"
/>
<
TextBlock
Text
=
"{Binding Name}"
/>
</
StackPanel
>
</
DataTemplate
>
Then the icons show up no problem. So any clues about what am I doing wrong? Why doesn't the DefaultImageSrc work for me in the Style? The paths are the same in both cases so its not a problem of the icon. I've tried fiddling with thigns and nothing seems to make the DefaultImageSrc work.
FYI I'm using RadControls for WPF Q1 2013 ( v.2013.1.403.40)
Thanks!
6 Answers, 1 is accepted
0
Hello Robert,
I wasn't able to reproduce this issue locally but I noticed in your code snippets that in the FileItemStyle Setter you're trying to apply the /Images/file.jpg as a DefaultImageSrc, while in the DataTemplate you've defined the /Images/file.png image as a source.
I'm not sure if this is intentional, but if it is please make sure that the Images folder contains both versions of the file - the jpg and the png. For your inconvenience, I also attached a sample solution based on the tutorial you mentioned. Please let me know if it works for you or if you have any additional questions.
All the best,
Tina Stancheva
the Telerik team
I wasn't able to reproduce this issue locally but I noticed in your code snippets that in the FileItemStyle Setter you're trying to apply the /Images/file.jpg as a DefaultImageSrc, while in the DataTemplate you've defined the /Images/file.png image as a source.
I'm not sure if this is intentional, but if it is please make sure that the Images folder contains both versions of the file - the jpg and the png. For your inconvenience, I also attached a sample solution based on the tutorial you mentioned. Please let me know if it works for you or if you have any additional questions.
All the best,
Tina Stancheva
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
0
Robert
Top achievements
Rank 1
answered on 02 May 2013, 03:37 PM
Hi Tina,
Thanks for your answer. I tried the project you sent and indeed that one works, so I decided to do some more experimentation to find out the differences between your project an mine.
My findings were that if you set the treeview to be UI virtualizing, then the icons no longer work. To test this, simply add:
telerik:TreeViewPanel.IsVirtualizing="True"
to your MainWindow's radTreeView definition and try it out. The icons will no longer appear. I don't know if this is by design or expected or if its considered a bug though.
Thanks!
-Robert
Thanks for your answer. I tried the project you sent and indeed that one works, so I decided to do some more experimentation to find out the differences between your project an mine.
My findings were that if you set the treeview to be UI virtualizing, then the icons no longer work. To test this, simply add:
telerik:TreeViewPanel.IsVirtualizing="True"
to your MainWindow's radTreeView definition and try it out. The icons will no longer appear. I don't know if this is by design or expected or if its considered a bug though.
Thanks!
-Robert
0
Hello Robert,
Unfortunately this is a known issue and it is logged in our PITS where you can track its progress. As a workaround you can bind the DefaultImageSource properties to business members.
Regards,
Tina Stancheva
the Telerik team
Unfortunately this is a known issue and it is logged in our PITS where you can track its progress. As a workaround you can bind the DefaultImageSource properties to business members.
Regards,
Tina Stancheva
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
0
BKR AG
Top achievements
Rank 1
answered on 23 Sep 2015, 01:21 PM
Hi,
are there any news on this topic? In the 2015 Version of Telerik UI for WPF the images still don't work if isVirtualizing is set to true.Unfortunately the control is extremely slow if i set this option to off.
I'm also not sure what you mean by "DefaultImageSource". Is this another property or do you mean DefaultImageSrc? And what do you mean by binding to business members? I tried the following xaml:
<
Setter
Property
=
"DefaultImageSrc"
Value
=
"{Binding ImagePath}"
></
Setter
>​
And bound it to the following Path
public
string
AxisImagePath {
get
{
return
"/res/Images/device.png"
; } }
Im trying to do it in the same way as you do it in one of your examples with a StyleSelector. But the image ist not shown
Thanks in Advance!
0
BKR AG
Top achievements
Rank 1
answered on 23 Sep 2015, 01:28 PM
Ok, forget it. :)
0
Hi Roland,
I am afraid that the DefaultImageSrc still behaves the same when it is set statically in Xaml and the treeview's UI virtualization is enabled. About the binding to business members - this means that you can define a property that holds the image path in the view model of the treeview item and bind it to its DefaultImageSrc property. Just like in the code snippet from your reply. I noticed that the snippet defines "AxisImagePath" property but the binding uses path to a property called "ImagePath". Can you please ensure that the property in the view model matches the property passed to the Binding and see if the issue still appears? I also attached a sample project demonstrating the described approach with the binding.
As a side note, there is no DefaultImageSource property - this is a typo in the Tina's reply.
Regards,
Martin
Telerik
I am afraid that the DefaultImageSrc still behaves the same when it is set statically in Xaml and the treeview's UI virtualization is enabled. About the binding to business members - this means that you can define a property that holds the image path in the view model of the treeview item and bind it to its DefaultImageSrc property. Just like in the code snippet from your reply. I noticed that the snippet defines "AxisImagePath" property but the binding uses path to a property called "ImagePath". Can you please ensure that the property in the view model matches the property passed to the Binding and see if the issue still appears? I also attached a sample project demonstrating the described approach with the binding.
As a side note, there is no DefaultImageSource property - this is a typo in the Tina's reply.
Regards,
Martin
Telerik
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Feedback Portal
and vote to affect the priority of the items