Hi,
I am creating a windows explorer type application using WPF, and want to use the icons that are within the Shell32.dll so that it matches what is in windows explorer. I have tried several different methods assigning the icon to the radtreeviewitem and none have worked.
Here is an excerpt from my code I am first checking to see if an image is contained in the imagelist before adding a new image to the list:
if (images.Images["Folders"] == null)
{
images.Images.Add("Folders", (System.Drawing.Icon)GetIcon(drive.Name, 0));
}
item.DefaultImageSrc = "Folders";
Here is the getIcon method:
private object GetIcon(string path, int openclose)
{
IntPtr hImgSmall;
SHFILEINFO shinfo = new SHFILEINFO();
hImgSmall = Win32.SHGetFileInfo(path, 0, ref shinfo, (uint)Marshal.SizeOf(shinfo), Win32.SHGFI_ICON | Win32.SHGFI_SMALLICON);
return System.Drawing.Icon.FromHandle(shinfo.hIcon);
}
I am not sure if this is even possible using the radtreeview of WPF. I moved this code into a program that was built using winforms and it works perfectly.
Thanks,
Jonathan
I am creating a windows explorer type application using WPF, and want to use the icons that are within the Shell32.dll so that it matches what is in windows explorer. I have tried several different methods assigning the icon to the radtreeviewitem and none have worked.
Here is an excerpt from my code I am first checking to see if an image is contained in the imagelist before adding a new image to the list:
if (images.Images["Folders"] == null)
{
images.Images.Add("Folders", (System.Drawing.Icon)GetIcon(drive.Name, 0));
}
item.DefaultImageSrc = "Folders";
Here is the getIcon method:
private object GetIcon(string path, int openclose)
{
IntPtr hImgSmall;
SHFILEINFO shinfo = new SHFILEINFO();
hImgSmall = Win32.SHGetFileInfo(path, 0, ref shinfo, (uint)Marshal.SizeOf(shinfo), Win32.SHGFI_ICON | Win32.SHGFI_SMALLICON);
return System.Drawing.Icon.FromHandle(shinfo.hIcon);
}
I am not sure if this is even possible using the radtreeview of WPF. I moved this code into a program that was built using winforms and it works perfectly.
Thanks,
Jonathan