How would I modify my current TreeView to support a parent node of 'Critical, Alert' and then the child nodes would be the messages of that severity type. I'm using an ObservableCollection that is tied to the TreeView. There is more data in each message type but I only want a few of them to be visible to the user. Then when a user clicks on one of the child nodes, pull the other data from that item in the collection and display it where it's needed. I added the ID as hidden because i'm not sure if I need something to reference that is unique to reference that item in the collection. I also want to default a different icon for each parent node, the child nodes wont have an icon.
Hope I describe this so it's understandable.
XMAL
<TreeView x:Name="tvMessages" HorizontalAlignment="Left" Height="262" Margin="10,37,0,0" VerticalAlignment="Top" Width="248">
<TreeView.ItemTemplate>
<HierarchicalDataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="{Binding Icon}" />
<TextBlock Text="{Binding Description}" />
<TextBlock Text="{Binding ID}" Visibility="Hidden" />
</StackPanel>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
MessageData
public class MessageData
{
public Guid ID { get; set; }
public string Severity { get; set; }
public string Description { get; set; }
public string ClientID { get; set; }
public string Specialty { get; set; }
public DateTime IssuedDate { get; set; }
}
Its a bit old, but this MSDN blog should get you in the right direction http://blogs.msdn.com/b/mikehillberg/archive/2009/10/30/treeview-and-hierarchicaldatatemplate-step-by-step.aspx