This article is currently in the process of being translated into Korean (~25% done).

The DataGrid control:

The DataGrid control

DataGrid 컨트롤은 GridView를 사용할 때 ListView와 매우 비슷하지만 많은 추가 기능을 제공합니다. 예를 들어 DataGrid는 사용자가 제공하는 데이터에 따라 열을 자동으로 생성 할 수 있습니다. 또한 DataGrid는 기본적으로 편집 가능하므로 최종 사용자가 기본 데이터 소스의 값을 변경할 수 있습니다.

DataGrid의 가장 일반적인 사용은 데이터베이스와 결합하는 것이지만 대부분의 WPF 컨트롤들 처럼 객체의 리스트와 같은 메모리 내 소스에서도 잘 작동합니다. 이것이 시연하기 훨씬 쉽기 때문에 해당 튜토리얼에서는 대부분 후자의 접근 방식을 사용합니다.

A simple DataGrid

You can start using the DataGrid without setting any properties, because it supports so much out of the box. In this first example, we'll do just that, and then assign a list of our own User objects as the items source:

<Window x:Class="WpfTutorialSamples.DataGrid_control.SimpleDataGridSample"
Title="SimpleDataGridSample" Height="180" Width="300">
    <Grid Margin="10">
<DataGrid Name="dgSimple"></DataGrid>
using System;
using System.Collections.Generic;
using System.Windows;

namespace WpfTutorialSamples.DataGrid_control
public partial class SimpleDataGridSample : Window
public SimpleDataGridSample()

List<User> users = new List<User>();
users.Add(new User() { Id = 1, Name = "John Doe", Birthday = new DateTime(1971, 7, 23) });
users.Add(new User() { Id = 2, Name = "Jane Doe", Birthday = new DateTime(1974, 1, 17) });
users.Add(new User() { Id = 3, Name = "Sammy Doe", Birthday = new DateTime(1991, 9, 2) });

dgSimple.ItemsSource = users;

public class User
public int Id { get; set; }

public string Name { get; set; }

public DateTime Birthday { get; set; }

That's really all you need to start using the DataGrid. The source could just as easily have been a database table/view or even an XML file - the DataGrid is not picky about where it gets its data from.

If you click inside one of the cells, you can see that you're allowed to edit each of the properties by default. As a nice little bonus, you can try clicking one of the column headers - you will see that the DataGrid supports sorting right out of the box!

The last and empty row will let you add to the data source, simply by filling out the cells.


As you can see, it's extremely easy to get started with the DataGrid, but it's also a highly customizable control. In the next chapters, we'll look into all the cool stuff you can do with the DataGrid, so read on.

This article has been fully translated into the following languages: Is your preferred language not on the list? Click here to help us translate this article into your language!