Sunday, February 27, 2011

DataGrid in WPF

This article shows you how to create and use a DataGrid control in WPF and XAML.

Note: This article is written using Visual Studio 2010 and .NET Framework 4.0.
Introduction

DataGrid element represents WPF DataGrid control in XAML.

<DataGrid
/
>

When you drag and drop a DataGrid control from Toolbox to your designer, position the control, this action adds following code to XAML. The Width and Height properties represent the width and the height of a DataGrid. The Name property represents the name of the control, which is a
unique identifier of a control. The Margin property sets the margin of placement of DataGrid on the window. The following code snippet sets the name, height, width, and margin of a DataGrid control.
<>
<DataGrid Height="148" HorizontalAlignment="Left" Margin="12,21,0,0" 

         Name="dataGrid1"
VerticalAlignment
="Top" Width="225"
/>
                                                      
Listing 1

No comments:

Post a Comment