WPF Controls - ListView, GridView, DataGrid, TabControl, Label, MVVM Frameworks - MVVM Light

WPF Tab Control - Templates

WPF TabControl provides two templates property for changing the UI for Header and Content area. ItemTemplate - Get/Set DataTemplate for TabItem Header. ContentTemplate - Get/Set DateTemplate for TabItem Content. ItemTemplate ItemTemplate is used for changing the DataTemplate of Header section of TabItem. By default, Header DataTemplate call the ToString meth...

Continue Reading

WPF Tab Control - Selection

TabControl provides two main properties for selection of Items. SelectedItem SelectedIndex TabControl SelectedItem SelectedItem property is used for getting and setting the selected object of WPF TabControl. You bind item list into the ItemsSource property of TabControl and set the SelectedItem property to object which you want to selected first. <Ta...

Continue Reading

WPF Tab Control - FlowDirection

FlowDirection in WPF TabControl is used for setting the content flow direction of UI elements in header and content area.  FlowDirection is an enum which has only two values: LeftToRight (Default) RightToLeft LeftToRight By default, any TabControl set the FlowDirection property to LeftToRight. In this, all the UI controls in header and cont...

Continue Reading

WPF Tab Control - TabStripPlacement

TabStripPlacement is an important propety of TabControl. It is used for setting the Header alignment relative to tab content. You can set below four values in TabStripPlacement. Left Top (Default) Right Bottom I have given all four examples of TabStripPlacement. Left Set header to left position like below: <TabControl x:Name="TabC...

Continue Reading

WPF Tab Control - Close Button

A very common requirement in TabControl is to show a close button (X) near the end of header of each TabItem. We can use ItemTemplate to customize the header section and show a close button (X) at the end of TabItem header. Close Button Example <Grid> <Grid.Resources> <DataTemplate x:Key="CustomHeaderTemplate"> <DockPanel Last...

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

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