This question is locked. New answers and comments are not allowed.
We are using Visual Studio 2008 and have a Project File with a Media folder underneath that holds images of icons, also within the project is the page's xaml and xaml.cs files.
We want to set a treeview item image icon dynamically based on certain conditions instead of at designtime from certain icons in the Media folder.
The name of the icon in my Media folder mentioned above is MYIMAGE.PNG. I have the following C# code I was testing but it isn't working:
BitmapImage bitmap = new BitMapImage();
string imagePath = "../Media/MYIMAGE.PNG";
bitmap.UriSource = new Uri(imagePath, UriKind.Relative);
((RadTreeViewItem)this.trvBookContent.ItemContainerGenerator.ContainerFromItem(trvBookContent.Items[0])).DefaultImageSrc = Convert.ToString(bitmap);
I also noticed there is a SelectedImageSrc and ExpandedImageSrc property.
Any ideas on how to set an image dynamically for a treeview item?
Thanks
We want to set a treeview item image icon dynamically based on certain conditions instead of at designtime from certain icons in the Media folder.
The name of the icon in my Media folder mentioned above is MYIMAGE.PNG. I have the following C# code I was testing but it isn't working:
BitmapImage bitmap = new BitMapImage();
string imagePath = "../Media/MYIMAGE.PNG";
bitmap.UriSource = new Uri(imagePath, UriKind.Relative);
((RadTreeViewItem)this.trvBookContent.ItemContainerGenerator.ContainerFromItem(trvBookContent.Items[0])).DefaultImageSrc = Convert.ToString(bitmap);
I also noticed there is a SelectedImageSrc and ExpandedImageSrc property.
Any ideas on how to set an image dynamically for a treeview item?
Thanks