New to Telerik UI for WPF? Download free 30-day trial

Data Formatting

GridViewDataColumn and GridViewComboBoxColumn allow you to format the displayed data by specifying an appropriate format string and assigning it to the DataFormatString property for the column.

Example 1: Set DataFormatString property of DateTime column

<telerik:GridViewDataColumn DataMemberBinding="{Binding OrderDate}" 
                Header="Order Date" 
                UniqueName="OrderDate" 
                DataFormatString="{} {0:dd, MMM, yyyy}" /> 

{} is the XAML escape sequence which allows subsequent values in the attribute to be interpreted as a literal. You can find more information in the MSDN Escape Sequence article.

Example 1: Set DataFormatString property of DateTime column

((GridViewDataColumn)this.radGridView.Columns["OrderDate"]).DataFormatString = "{0:dd, MMM, yyyy}"; 
// or 
((GridViewDataColumn)this.radGridView.Columns["OrderDate"]).DataFormatString = "dd, MMM, yyyy"; 
DirectCast(Me.radGridView.Columns("OrderDate"), GridViewDataColumn).DataFormatString = "{0:dd, MMM, yyyy}" 
' or 
DirectCast(Me.radGridView.Columns("OrderDate"), GridViewDataColumn).DataFormatString = "dd, MMM, yyyy" 

Figure 1: DateTime column with custom DataFormatString

Telerik WPF DataGrid Data Formatting 1

The DataFormatString property uses the string.Format method. To learn more, check the string.Format MSDN article. The resulting string is also dependent on the IsLocalizationLanguageRespected property.

To learn more about formatting visit the Formatting Overview chapter in MSDN.

See Also

In this article