How can I achieve the following attached Image in GridView? In the example (https://docs.telerik.com/devtools/wpf/controls/radgridview/columns/column-headers), the data columns are known but in my case, I don't know the column headers to do such example. Any suggestions on how to achieve this?
5 Answers, 1 is accepted
0
Hello Joseph,
Thank you for the provided image.
Though I am not completely sure what your setup is, you should be able to achieve your goal by setting the Header property of a given column programmatically when the needed data is known. Would such an approach be possible for you or I am missing something?
Regards,
Stefan
Progress Telerik
Thank you for the provided image.
Though I am not completely sure what your setup is, you should be able to achieve your goal by setting the Header property of a given column programmatically when the needed data is known. Would such an approach be possible for you or I am missing something?
Regards,
Stefan
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0

Joseph
Top achievements
Rank 1
answered on 27 Mar 2018, 03:02 PM
Hello Stefan,
Thank you for that suggestion. However, as I've stated, the challenge for me is that the column headers are not known.
In the xaml, here is what I got.
<
telerik:RadGridView
x:Name="myDataGrid" ShowGroupPanel
=
"False"
IsFilteringAllowed
=
"False"
RowIndicatorVisibility
=
"Collapsed"
SelectionUnit
=
"Cell"
ColumnWidth
=
"120"
/>
Then in the xaml.cs, here is what I got
DataTable dt = new DataTable();
foreach (var item in ColumnNames)
{
dt.Columns.Add(item, typeof(string));
}
myDataGrid.AutoGenerateColumns = true;
myDataGrid.ItemsSource = dt.DefaultView;
0
Accepted
Hello Joseph,
Since you are using auto generated columns, you can hook up to the AutoGeneratingColumn event of the control. Through the event arguments you can access each column and manipulate its Header property as per your requirements.
Can you please check this out?
Additionally, you can take a look at the Defining Columns help article.
Regards,
Stefan
Progress Telerik
Since you are using auto generated columns, you can hook up to the AutoGeneratingColumn event of the control. Through the event arguments you can access each column and manipulate its Header property as per your requirements.
Can you please check this out?
Additionally, you can take a look at the Defining Columns help article.
Regards,
Stefan
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0

Joseph
Top achievements
Rank 1
answered on 06 Apr 2018, 10:15 PM
Stefan,
That did it. As a reference for others, here is what I did.
private void myDataGrid_AutoGeneratingColumn(object sender, GridViewAutoGeneratingColumnEventArgs e)
{
column.HeaderTextAlignment = TextAlignment.Center;
column.HeaderTextWrapping = TextWrapping.Wrap;
column.TextWrapping = TextWrapping.Wrap;
column.Width = 150;
}
Thank you,
JA
0
Hello Joseph,
Thank you for sharing your solution.
Regards,
Martin Ivanov
Progress Telerik
Thank you for sharing your solution.
Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.