Click here to Skip to main content
15,939,960 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi folks.
I need a data grid in wpf with 10 cells.
But the first 3 columns be in first cell in vertical order. And ofcourse the font size will be less.
So what you will see in monitor is a row with 7 columns but the first column have 3 cells vertically.
I made a sample of what I need in excel. Please see the attachment.
My Sample Grid — Postimages[^]

Please kindly help me on this.

What I have tried:

Actually I searched a lot, but I could not find any solution.
Updated 30-Dec-23 0:04am
CHill60 29-Dec-23 6:30am    
I can't use your link, but I think you'll have to build a custom control - probably a combination of a 1 by 3 datagrid next to a 1 by 7 datagrid. Trying to populate it will be fun.
Sh.H. 29-Dec-23 6:34am    
CHill60 29-Dec-23 7:54am    
[no name] 29-Dec-23 14:45pm    
DataGrid is too "abstract" (in this case); and used mainly for "variable" rows and colums. You know what you have (3x7): use a "Grid" (Panel); WrapPanel or UniformGrid. (Or combinations of StackPanels; oriented horizontally or vertically). Or all of the above ... except DataGrid.
Sh.H. 30-Dec-23 5:44am    
I do not need a 3x7 grid. I need a 1x10 grid, which the first 3 cells would be vertical.

(After looking at your picture ...) Use a "DataGridTemplateColumn" to define a "stack" for the first cell. See the "Publish Date" in the example.

DataGridTemplateColumn.CellTemplate Property (System.Windows.Controls) | Microsoft Learn[^]
Share this answer
Sh.H. 30-Dec-23 15:22pm    
Thanks Gerry Schmitz.
But it is not what I want. I do not want to change the designing of first cell.
I do not need a 3x7 DataGrid.
What I need is a 1x10 DataGrid, but just the first 3 columns, shows in vertical way.
Graeme_Grant 5-Jan-24 7:11am    
Why not? It is how I would do it. It is a custom cell.
Regarding your question about merging cells in a WPF grid, check out the below links, which offers a solution aligned with your requirements.
How to merge datacells in WPF DataGridView[^]
Wpf – Datagrid, Merge/Combine rows, cells and columns – iTecNote[^]
Share this answer
Take a look at WPF: A Beginner's Guide - Part 1 of n[^] by the excellent Sacha Barber.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900