The only reasonable solution I've found is to create a third ViewModel type which would wrap either of the first two types (Resource or Property) and provide common properties to bind to: (e.g. children). This still is not very optimal, though, if the two types need very different templates because at that point, I am using the VisualStateManager
to switch between templates for the data.
<HierarchicalDataTemplate x:Key="TreeItemTemplate"
ItemSource="{Binding Children}">
<ContentPresenter Content="{Binding}">
<VisualStateManager.Groups>
<VisualStateGroup>
<VisualState Name="IsResource">
<!-- set resource template -->
</VisualState>
<VisualState Name="IsProperty">
<!-- set property template -->
</VisualState>
</VisualStateGroup>
</VisualStateManager.Groups>
</ContentPresenter>
</HierarchicalDataTemplate>
MojoFilter
2010-09-27 15:53:44