I have a datagrid in my form which has columns for each of Question Types.
I want that column to be split into two as i want to accept number of compulsory and number of optional questions for each of the question type in the subsequent columns.
I have achieved this in winforms, thanks to stackoverflow.com.
I am trying to achieve the same in WPF
Thanks in advance
I guess this is the
DataGridlayout you want…. right?WPF datagrid doesnt support this readily. But you can do some stretchy coding. The code like below can split the headers. You need to take caution that …
Have some custom styles for
DataGridHeadersHave columns arranged like this…
So basically you use the same default header layout of
DataGridbut hack it in a way that two headers look like they are joined together.C#
DataGride.g.x:Name="MyDataGrid".Keep all the styles in XAML in
<DataGrid.Resources ..>tag. Make sure that they havex:Keyset. e.g.x:Key="SplitHeaderLeftStyle"&x:Key="SplitHeaderRightStyle"in your C# code when you add columns, set the styles by their
Key.