-2

I would need to create a WPF component that accepts a row and column layout ​​as input (2 rows and 2 columns, 3 rows and 3 columns, etc.).

So I took a listview and as itempaneltemplate I use a uniformgrid.

When I add an element to the listview (which is a usercontrol, added via a datatemplate) it is set according to the uniform grid layout.

What I can't implement is that when I set up a layout, I would like the boxes that will then be filled by my user control at runtime to be visible even when the listview is empty.

Sample Image: enter image description here

EldHasp
  • 6,079
  • 2
  • 9
  • 24
Mark
  • 3
  • 2
  • Not sure what exactly you mean with "visible". If you set both Columns and Rows of the UniformGrid, you should get an C x R grid even if the children count is less than C*R. – Clemens Jun 07 '21 at 14:46
  • With visible i mean that i my layout it's 3 x 3 e.g. I want to see 9 box with border for example even if my listview haave only one element – Mark Jun 07 '21 at 15:59
  • Which border? You do see a 3x3 layout if you set both properties. – Clemens Jun 07 '21 at 16:02
  • I've added a picture in the post of what I want to achieve – Mark Jun 08 '21 at 06:58

1 Answers1

0

The Uniformgrid is just a panel. She has no means of marking boundaries. In each cell, you need to place a Border with its own borders. And in the Content Border (where necessary) place the output of the required element.

One example: Draw samurai sudoku grid on WPF

EldHasp
  • 6,079
  • 2
  • 9
  • 24