Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1585
Set Expanded/CollapsedIcon Programatically
posted

How would I set an icon for each programatically?

 

I create a new XamWebTreeItem as follows...

XamWebTreeItem xamWebTreeItem = new XamWebTreeItem();
xamWebTreeItem.Header = node.ItemName;

xamWebTreeItem.ExpandedIcon = ??

xamWebTreeItem.CollapsedIcon =??

 

I tried

 StreamResourceInfo r = Application.GetResourceStream(new Uri("/SilverlightApp;component/Images/test.jpg", UriKind.Relative));


                    BitmapImage bmp = new BitmapImage();
                    bmp.SetSource(r.Stream);

                    xamWebTreeItem.ExpandedIcon = bmp;

 

The image does not show up.

I can do this and the icon will show...

 <igTree:XamWebTree.ExpandedIconTemplate>
    <DataTemplate>
      <Image Source="/SilverlightApp;component/Images/test.gif" />
    </DataTemplate>
  </igTree:XamWebTree.ExpandedIconTemplate>

 

 

 

 

 

  • 1585
    Verified Answer
    posted

    Instead of setting the CollapsedIcon and ExpandedIcon to an object of type BitmapImage, I set it to a object of type Image and it worked. Problem solved.