I've got a class structured like this:
public class WTRun : INotifyPropertyChanged
{
public WTRun()
{
}
# Local variable definitions removed
# Property gets & sets removed
# NotifyPropertyChanged code removed
public Guid RunId
public int RunNumber
public DateTime? RunStartTime
public DateTime? RunEndTime
public string RunComment
public int MapId
public RunConfiguration Configuration
public ObservableCollection<StepMetric> StepMetrics
public ObservableCollection<BlockMetric> BlockMetrics
public ObservableCollection<Medusa> Medusas
public ObservableCollection<PIV> PIVs
public ObservableCollection<CMotion> CMotions
}
The class is wrapped in an ObservableCollection and then bound to a TreeView. I'm getting stuck as to how to set the TreeView up so that it shows the items correctly.
I want the TreeView to look like this:
Root
+--(RunNumber)
| +--"StepMetrics"
| | +--(StepMetric IDs)
| +--"BlockMetrics"
| | +--(BlockMetric IDs)
| +--"Medusas"
| | +--(Medusa IDs)
| +--"PIVs"
| | +--(PIV IDs)
| +--"CMotions"
| +--(CMotion IDs)
|--(RunNumber)
...etc
I've been trying with had a stab at doing it with Templates, but can only get the RunNumbers to appear so far:
<TreeView.Resources>
<HierarchicalDataTemplate DataType="{x:Type VMEntities:WTRun}" >
<TextBlock Text="{Binding RunNumber }" Margin="1" />
</HierarchicalDataTemplate>
<HierarchicalDataTemplate DataType="{x:Type VMEntities:BlockMetric}">
<TextBlock Text="{Binding BlockIndex}"/>
</HierarchicalDataTemplate>
</TreeView.Resources>
This is obviously not a complete attempt...
Whats the right way to do this?