■ CollectionViewSource 엘리먼트를 사용하는 방법을 보여준다.
▶ 예제 코드 (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 |
<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" Width="800" Height="600" Title="CollectionViewSource 엘리먼트 사용하기" FontFamily="나눔고딕코딩" FontSize="16"> <Window.Resources> <local:TaskCollection x:Key="TaskCollectionKey" /> <CollectionViewSource x:Key="CollectionViewSourceKey" Source="{StaticResource TaskCollectionKey}"> <CollectionViewSource.SortDescriptions> <scm:SortDescription PropertyName="ProjectName" /> <scm:SortDescription PropertyName="Completed" /> <scm:SortDescription PropertyName="DueDate" /> </CollectionViewSource.SortDescriptions> <CollectionViewSource.GroupDescriptions> <PropertyGroupDescription PropertyName="ProjectName" /> <PropertyGroupDescription PropertyName="Completed" /> </CollectionViewSource.GroupDescriptions> </CollectionViewSource> </Window.Resources> ... </Window> |
※ TaskCollection 객체는 'DataGrid 클래스 : INotifyPropertyChanged, IEditableObject 인터페이스 구현 객체 정의하기'를 참조한다.