WPF DataGrid - Auto Generate Columns

AutoGenerateColumns property automatically generate columns for display in UI from the bounded data source. It takes every public property in bounded data source to generate columns. For example, if you bind to below Employee class to DataGrid: public class Employee { protected int Property1 { get; set; } private int Property2 { get; set; } static int Propert...

Continue Reading

WPF DataGrid - Common Tasks

Table of Contents Change WPF DataGrid Selected Row Background Color WPF DataGrid Select All Checkbox Change Alternate Row Background Color Change the order (Reorder) of Auto Generated Columns Set Auto Generated Column ReadOnly Change WPF DataGrid Selected Row Background Color To change the background color of selected row of WPF DataGrid, you have two ...

Continue Reading

WPF DataGrid - Custom Columns

In the last tutorial AutoGenerateColumns, I have shown how DataGrid automatically shows different columns based on the data types of data. But by using the Columns property, you can change how columns are generated and of which control. By default, WPF provides 5 different types of custom columns shown below: Column Type Display Da...

Continue Reading

WPF DataGrid - Filtering

WPF DataGrid provides a way to filter its bounded list. In the filter method, you can choose only those items from the list that you want to show in WPF DataGrid. Rest items will be hidden. DataGrid uses ListCollectionView class for filtering list of items. ListCollectionView ListCollectionView is a special class which is used for grouping, sorting, and filter it&#...

Continue Reading

WPF DataGrid - Grouping

WPF DataGrid is also used for showing group of items DataGrid use ListCollectionView class for grouping the associated list. DataGrid GroupStyle.ContainerStyle provides a way to display Group Item detail and its associated items. ListCollectionView Class ListCollectionView constructor takes an IList collection and has a GroupDescriptions list property. In the Gr...

Continue Reading

How to Remove Row/Column Header in WPF DataGrid?

WPF DataGrid provides a HeadersVisibility property to hide Row Headers and Column Headers. HeaderVisibility possible values are: All - Both row and column headers are visible. Row - Only row headers are visible and column headers are hidden. Column - Only column headers are visible and row headers are hidden. None - Both row and column headers are hidden. ...

Continue Reading

WPF DataGrid Introduction Tutorial

WPF DataGrid control is used for display and edit tabular data in rows and columns. DataGrid control is introduced in .NET 4.0. DataGrid control main features are: Bind to any collection that implements IEnumerable interface Auto generate data rows and columns based on bounded data. Provides different row selection-modes: Single/Extended Provides options for grou...

Continue Reading

WPF DataGrid - Selection Mode

WPF DataGrid provides different properties to select, unselect different rows and columns of grid. Single/Extended The SelectionMode property is used for selecting single/multiple row and columns. This property is an enum which have two values: Single Extended (Default) Single Single allows you to select only one row or column in the DataGrid. Colum...

Continue Reading

WPF Dispatcher - Introduction and How to use?

Before we learn what is dispatcher and why we need it, we need to understand what is the apartments of the Thread. Thread Apartments All objects in the process are grouped into Apartments. There are two types of apartments in Threads: Single-Threaded Apartments Multi-Threaded Apartments Single-Threaded Apartment (STA) Single-threaded apartments cont...

Continue Reading

WPF GridSplitter

WPF GridSplitter control gives user to resize the columns width and rows height. WPF Grid divides available space in rows and columns. When we define the RowDefinitions and ColumnDefinitions, we specify how much space a particular row or column should take. A user has no option to resize width and height later. In the below example, I have divided the Grid into two colu...

Continue Reading

Join our newsletter and get an occasional email with a technology and DotNetPattern.com news update.