■ HierarchicalDataTemplate 엘리먼트의 DataType 속성을 사용해 트리 구조 데이터를 바인딩하는 방법을 보여준다.
▶ 예제 코드 (XAML)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
<Window.Resources> <ResourceDictionary> <HierarchicalDataTemplate DataType="{x:Type local:ProjectObject}" ItemsSource="{Binding Path=ProjectStageCollection}" /> <HierarchicalDataTemplate DataType="{x:Type local:ProjectStage}" ItemsSource="{Binding Path=TaskCollection}" /> </ResourceDictionary> </Window.Resources> ... <Grid xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"> <dxg:TreeListControl x:Name="treeListControl"> <dxg:TreeListControl.Columns> <dxg:TreeListColumn FieldName="Name" AllowSorting="True" /> <dxg:TreeListColumn FieldName="Executor" AllowSorting="True" /> </dxg:TreeListControl.Columns> <dxg:TreeListControl.View> <dxg:TreeListView x:Name="treeListView" TreeDerivationMode="HierarchicalDataTemplate" /> </dxg:TreeListControl.View> </dxg:TreeListControl> </Grid> |
※ ProjectObject, ProjectStage, Task 클래스는 'TreeListControl 클래스 : HierarchicalDataTemplate를 통해 트리 구축하기'를 참조한다.