첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
본 블로그는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 블로그 콘텐츠 향상을 위해 쓰여집니다.

728x90
반응형
728x170

▶ Employee.cs

namespace TestProject
{
    /// <summary>
    /// 직원
    /// </summary>
    public class Employee
    {
        #region 이름 - FirstName

        /// <summary>
        /// 이름
        /// </summary>
        public string FirstName { get; set; }

        #endregion

        #region 성 - LastName

        /// <summary>
        /// 성
        /// </summary>
        public string LastName { get; set; }

        #endregion

        #region 직업 - Occupation

        /// <summary>
        /// 직업
        /// </summary>
        public string Occupation { get; set; }

        #endregion
    }
}

 

728x90

 

▶ EmployeeCollection.cs

using System.Collections.ObjectModel;

namespace TestProject
{
    /// <summary>
    /// 직원 컬렉션
    /// </summary>
    public class EmployeeCollection : ObservableCollection<Employee>
    {
    }
}

 

300x250

 

▶ 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:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
    xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid"
    xmlns:local="clr-namespace:TestProject"
    Width="600"
    Height="450"
    Title="그룹핑, 정렬 사용하기">
    <Window.Resources>
        <local:EmployeeCollection x:Key="EmployeeObservableCollectionKey">
            <local:Employee FirstName="Jenny"      LastName="Beland"     Occupation="Writer"           />
            <local:Employee FirstName="Francois"   LastName="Carignan"   Occupation="Developer"        />
            <local:Employee FirstName="Pascal"     LastName="Bourque"    Occupation="Developer"        />
            <local:Employee FirstName="Michel"     LastName="Fortin"     Occupation="Developer"        />
            <local:Employee FirstName="Marc"       LastName="Laroche"    Occupation="Developer"        />
            <local:Employee FirstName="Pierre-Luc" LastName="Ledoux"     Occupation="Developer"        />
            <local:Employee FirstName="Mathieu"    LastName="Drimonakos" Occupation="TechnicalSupport" />
            <local:Employee FirstName="Catherine"  LastName="Sauzede"    Occupation="Infograph"        />
        </local:EmployeeCollection>
        <xcdg:DataGridCollectionViewSource x:Key="DataGridCollectionViewSourceKey"
            ItemType="{x:Type local:Employee}"
            Source="{StaticResource EmployeeObservableCollectionKey}">
            <xcdg:DataGridCollectionViewSource.GroupDescriptions>
                <xcdg:DataGridGroupDescription PropertyName="Occupation" />
            </xcdg:DataGridCollectionViewSource.GroupDescriptions>
            <xcdg:DataGridCollectionViewSource.SortDescriptions>
                <scm:SortDescription
                    PropertyName="Occupation"
                    Direction="Ascending" />
            </xcdg:DataGridCollectionViewSource.SortDescriptions>
        </xcdg:DataGridCollectionViewSource>
    </Window.Resources>
    <Grid>
        <xcdg:DataGridControl x:Name="dataGridControl"
            ItemsSource="{Binding Source={StaticResource DataGridCollectionViewSourceKey}}" />
    </Grid>
</Window>

 

728x90
반응형
그리드형
Posted by 사용자 icodebroker
TAG , , ,

댓글을 달아 주세요