첨부 소스 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

TestProject.zip
다운로드

▶ MainWindow.xaml

<Window x:Class="TestProject.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
    xmlns:local="clr-namespace:TestProject"
    Width="800"
    Height="600"
    Title="언바운드 모드 트리 구축하기"
    FontFamily="나눔고딕코딩"
    FontSize="16">
    <Grid>
        <dxg:TreeListControl x:Name="treeListControl">
            <dxg:TreeListControl.Columns>
                <dxg:TreeListColumn FieldName="Name"     />
                <dxg:TreeListColumn FieldName="Executor" />
            </dxg:TreeListControl.Columns>
                <dxg:TreeListControl.View>
                <dxg:TreeListView Name="treeListView">
                    <dxg:TreeListView.Nodes> 
                        <dxg:TreeListNode> 
                            <dxg:TreeListNode.Content> 
                                <local:ProjectObject
                                    Name="Project : Betaron"
                                    Executor="Destiny Tabisola" /> 
                            </dxg:TreeListNode.Content> 
                            <dxg:TreeListNode.Nodes>
                                <dxg:TreeListNode> 
                                    <dxg:TreeListNode.Content> 
                                        <local:ProjectObject
                                            Name="Development"
                                            Executor="Kairra Hogg" /> 
                                    </dxg:TreeListNode.Content> 
                                    <dxg:TreeListNode.Nodes>
                                        <dxg:TreeListNode> 
                                            <dxg:TreeListNode.Content> 
                                                <local:ProjectObject
                                                    Name="Coding"
                                                    Executor="Sabato Durley" /> 
                                            </dxg:TreeListNode.Content> 
                                        </dxg:TreeListNode>                            
                                    </dxg:TreeListNode.Nodes>
                                </dxg:TreeListNode>                            
                            </dxg:TreeListNode.Nodes>
                        </dxg:TreeListNode> 
                    </dxg:TreeListView.Nodes> 
                </dxg:TreeListView>
            </dxg:TreeListControl.View>
        </dxg:TreeListControl>
    </Grid>
</Window>

 

728x90

 

▶ MainWindow.xaml.cs

using System.Windows;

using DevExpress.Xpf.Grid;

namespace TestProject
{
    /// <summary>
    /// 메인 윈도우
    /// </summary>
    public partial class MainWindow : Window
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - MainWindow()

        /// <summary>
        /// 생성자
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();

            BuildTree();
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Private

        #region 트리 구축하기 - BuildTree()

        /// <summary>
        /// 트리 구축하기
        /// </summary>
        private void BuildTree()
        {
            TreeListNode rootTreeListNode = CreateRootTreeListNode(new ProjectObject() { Name = "Project : Stanton", Executor = "Nicholas Llams" });

            TreeListNode treeListNode = CreateChildTreeListNode(rootTreeListNode, new ProjectObject() { Name = "Information Gathering", Executor = "Ankie Galva" });

            CreateChildTreeListNode(treeListNode, new ProjectObject() { Name = "Design", Executor = "Reardon Felton" });
        }

        #endregion
        #region 루트 트리 리스트 노드 생성하기 - CreateRootTreeListNode(projectObject)

        /// <summary>
        /// 루트 트리 리스트 노드 생성하기
        /// </summary>
        /// <param name="projectObject">프로젝트 객체</param>
        /// <returns>트리 리스트 노드</returns>
        private TreeListNode CreateRootTreeListNode(ProjectObject projectObject)
        {
            TreeListNode treeListNode = new TreeListNode(projectObject);

            this.treeListView.Nodes.Add(treeListNode);

            return treeListNode;
        }

        #endregion
        #region 자식 트리 리스트 노드 생성하기 - CreateChildTreeListNode(parentTreeListNode, projectObject)

        /// <summary>
        /// 자식 트리 리스트 노드 생성하기
        /// </summary>
        /// <param name="parentTreeListNode">부모 트리 리스트 노드</param>
        /// <param name="projectObject">프로젝트 객체</param>
        /// <returns>자식 트리 리스트 노드 객체</returns>
        private TreeListNode CreateChildTreeListNode(TreeListNode parentTreeListNode, ProjectObject projectObject)
        {
            TreeListNode treeListNode = new TreeListNode(projectObject);

            parentTreeListNode.Nodes.Add(treeListNode);

            return treeListNode;
        }

        #endregion
    }
}
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요