I understand how to add pictures to nodes of my tree using this code.
<ig:NodeLayout Key="sectionKey" TargetTypeName="Sections" IsDraggable="True" IsDropTarget="True" CheckBoxMemberPath="IsChecked" DisplayMemberPath="SectionName">
<!--<ig:NodeLayout.CollapsedIconTemplate> <DataTemplate> <Image Source="my picture" > </DataTemplate> </ig:NodeLayout.CollapsedIconTemplate>-->
</ig:NodeLayout>
what i do not know how to do is dynamically add the pics at run time. i have chart items and graph items, each needs a different picture. Using the code above it only allows me to associate one picture with all items added to my xamdatatree. Any help would be appreciated, thanks in advance
Hello petetataliba,
I have been looking into your requirement and what I can suggest is use a DataTemplate like this one:
ig:NodeLayout.ExpandedIconTemplate>
<DataTemplate >
<Image Height="32" Width="32" Source="{Binding Path=Data.ExpandImage}"/>
</DataTemplate>
</ig:NodeLayout.ExpandedIconTemplate>
And add a property to your underlying object of type string, or Uri, or BitmapImage called ExpandImage, which you can set dynamically.
Please let me know if you require any further assistance on this matter.
{ public class Sections { public Sections(string name, List<Fields> fields, bool isChecked) { SectionName = name.Trim(); IsChecked = isChecked; GraphOrChart = "/ReportCustomization;component/Layouts/Resources/base_charts_16.png"; Fields = fields; } public string SectionName { get; set; } public string GraphOrChart { get; set; } public bool IsChecked { get; set; } public List<Fields> Fields { get; set; }
<ig:NodeLayout Key="sectionKey" TargetTypeName="Sections" IsDraggable="True" IsDropTarget="True" CheckBoxMemberPath="IsChecked" DisplayMemberPath="SectionName"> <ig:NodeLayout.CollapsedIconTemplate> <DataTemplate DataType="Sections" > <Image> <Image.Source> <Binding Path="Sections.GraphOrChart" /> </Image.Source> </Image> </DataTemplate> </ig:NodeLayout.CollapsedIconTemplate> </ig:NodeLayout>
I added a string to my object that contains the path to an image. I am unsure how to bind the path correctly as the code above does not work. The image does not show up in my xamdatatree.