Hi
I trying to set collapse/expand icon to xamTreeItem in code-behind.(source code attached)
I want to acquire the icon from the resource dynamically and to set it. XamTreeItem rootItem = new XamTreeItem();rootItem.Header = "Root";Image parentCollapsedIcon = this.Resources["collaspedParentIcon"] as Image;Image parentExpandIcon = this.Resources["expandParentIcon"] as Image;
rootItem.CollapsedIcon = parentCollapsedIcon;rootItem.ExpandedIcon = parentExpandIcon;
but ManagedRuntimeError has shown.Is there an idea to solve this problem?
regards.
Hi,
Your source code is the same movement as my expectation. Thank you. I'm sorry that the reply is delayed.
In case it's useful: here is another sample, this time using BitmapImages as resources in XAML.
Hi Emory,
You don't have to define the images as resources in XAML; as long as you know where the .png files are relative to the .xap, you can instantiate a new Image object in the code-behind using the appropriate Uri.
See the attached sample, and let me know if it works for you.