Tutorials - C#, WPF, ASP.NET MVC, WCF, Entity Framework, AngularJS and MVVM Frameworks - MVVM Light - DotNetPattern.com

C# Reflection - Type class

A Type class is an important class in C# reflection. Type class represents class types, interface types, array types, value types, enum types, type parameters, generic type definitions, and open/closed generic types. Type class helps you to find properties, methods, events, fields, and constructors declared in a type. It also provides us the Assembly in which the type is dec...

Continue Reading

C# Reflection - MemberInfo Class

MemberInfo class provides a quick look of all the members in a Type. Below is the same code to get all members of a Type. static void Main(string[] args) { Type type = typeof(Program); foreach(MemberInfo member in type.GetMembers()) { Console.WriteLine(member.Name + ":" + member.MemberType); } } MemberInfo MemberType property MemberInfo prov...

Continue Reading

C# Reflection - Getting Constructors

C# reflection Type class provides two methods for getting the constructors in any Type. GetConstructors() //Returns all the constructors GetConstructor() //Returns only the specific constructor with match your given criteria. By default, all the above methods returns public constructors of a Type. To get the private, protected, and static constructors you have to u...

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

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

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

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