[DEVEXPRESS/WPF] TreeListView 엘리먼트 : ChildNodesSelector 속성을 사용해 트리 구조 데이터 바인딩 하기 (TreeDerivationMode 속성 : ChildNodesSelector)
DevExpress/WPF 2014. 3. 17. 09:00728x90
반응형
728x170
▶ C#
using System.Collections;
using DevExpress.Xpf.Grid;
/// <summary>
/// 커스텀 자식 노드 셀렉터
/// </summary>
public class CustomChildNodesSelector : IChildNodesSelector
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 자식 선택하기 - SelectChildren(item)
/// <summary>
/// 자식 선택하기
/// </summary>
/// <param name="item">항목</param>
/// <returns>IEnumerable 객체</returns>
public IEnumerable SelectChildren(object item)
{
if(item is Task)
{
return null;
}
else if(item is ProjectStage)
{
return (item as ProjectStage).TaskCollection;
}
else if(item is ProjectObject)
{
return (item as ProjectObject).ProjectStageCollection;
}
return null;
}
#endregion
}
728x90
▶ XAML
<Window.Resources>
<ResourceDictionary>
<local:ViewModel x:Key="ViewModelKey" />
<local:CustomChildNodesSelector x:Key="CustomChildNodesSelectorKey" />
</ResourceDictionary>
</Window.Resources>
<Grid xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid">
<dxg:TreeListControl x:Name="treeListControl"
DataContext="{StaticResource ViewModelKey}"
ItemsSource="{Binding ProjectObjectCollection}">
<dxg:TreeListControl.Columns>
<dxg:TreeListColumn FieldName="Name" AllowSorting="True" />
<dxg:TreeListColumn FieldName="Executor" AllowSorting="True" />
<dxg:TreeListColumn FieldName="State" AllowSorting="True" />
</dxg:TreeListControl.Columns>
<dxg:TreeListControl.View>
<dxg:TreeListView x:Name="treeListView"
TreeDerivationMode="ChildNodesSelector"
ChildNodesSelector="{StaticResource CustomChildNodesSelectorKey}" />
</dxg:TreeListControl.View>
</dxg:TreeListControl>
</Grid>
※ ProjectObject, ProjectStage, Task 클래스는 'TreeListControl 클래스 : 자식 노드 셀렉터를 통해 계층적 데이터 바인딩 구현하기'를 참조한다.
728x90
반응형
그리드형(광고전용)
댓글을 달아 주세요