Infragistics Data Grid in windows from 💅🧛‍♂️

Let’s Start

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" />

 

Data Binding

The ItemSource property of DataGrid is the key to data binding. You can bind any data source that implements IEnuemerable. Each row in the DataGrid is bound to an object in the data source and each column in the DataGrid is bound to a property of the data source objects.

In this example, we will create a collection of objects and bind it to a DataGrid control.

First, we are going to add a class to the project. The Author class looks like Listing 2 that has ID, Name, DOB, BookTitle, and IsMVP members.

   

Data Binding

The ItemSource property of DataGrid is the key to data binding. You can bind any data source that implements IEnuemerable. Each row in the DataGrid is bound to an object in the data source and each column in the DataGrid is bound to a property of the data source objects.

In this example, we will create a collection of objects and bind it to a DataGrid control.

First, we are going to add a class to the project. The Author class looks like Listing 2 that has ID, Name, DOB, BookTitle, and IsMVP members.

public class Author

{

public int ID { get; set; }

public string Name { get; set; }

public DateTime DOB { get; set; }

public string BookTitle { get; set; }

public bool IsMVP { get; set; }

}

 

Similar Articles
Red Ant Corp
Founded in 2012 by Red Ant Corp, Red Ant Corp & Associates Consulting (Red Ant Corp).