Short Vesion:
I need to display a hierarchy ( TreeView) of elements of different types, and I'm not sure how to do this in Silverlight. In WPF, it is easy to define patterns ( HierarchicalDataTemplate) based on types, but this feature is not available in Silverlight. It seems that in Silverlight you need to apply the same template to all the children of a particular node, so you will get one single monster template that handles all possible node types that apply to each node.
Long version (with an example):
To give a more specific (but far-fetched) example, we will consider the tree structure of archives in different folders, where each archive can contain photos, songs and other archives. Each folder can contain several subfolders and archives.
|-Folder
|-Folder
|-Folder
|-Archive
| Photo1
| Photo2
| Song1
| Song2
|-Archive
| Photo1
| Song1
|-Archive
| Photo1
| Photo2
| Photo3
Each type in the tree (folder, archive, photo, song) is displayed differently. The obvious solution was to create HierarchicalDataTemplatefor each type of item displayed. Unfortunately, I cannot find a good way to do this, because it seems that you need to specify one type of template for all the children of the node ( ItemsSource={Binding ...}, ItemsTemplate={StaticResource TemplateForAllChildren}) elements .
... , . , , . , , , , , , . .
, ( w633), ?
!
:
, , . , .
TreeView, :
: /
:
: ,
:
, - 1 HierarchicalDataTemplate, , , , , , , , , node.
WPF node, node . , Silverlight.
!