1

I need to display a 1 pixel wide border around all wrap panel cells, kinda like excel grid. Unfortunately the wrap panel does not implement the grid ShowGridLines property. I can't put a border inside every cell because adjacent cells will have a 2 pixel border instead of 1 pixel.

Since the wrap panel arranges it's layout dynamically and does not expose it's properties I can't evaluate the correct value for a border inside a cell. Any workaround possible?

double-beep
  • 5,031
  • 17
  • 33
  • 41
user275587
  • 690
  • 8
  • 21

1 Answers1

3

There is no way to show grid lines because it's just not a grid. Even in a WPF grid control, you have very little control over the appearance of lines: How can I change the color of the gridlines of a Grid in WPF?. They're really just for debugging. The workaround is to put a border inside each cell that only has thickness on the bottom and on the right: BorderThickness="0,0,1,1"

Community
  • 1
  • 1
Eric Mickelsen
  • 10,309
  • 2
  • 30
  • 41
  • I'm aware of "everything" you said. Although, the proposed workaround is so simple I feel stupid, still need to add a "1,1,0,0" border around the whole she-bang to get it right. – user275587 May 26 '10 at 02:44
  • In fact your workaround doesn't work, when a wrapped cell below is larger then the one above, no line is drawn at the top of the cell. – user275587 Jun 13 '10 at 21:22
  • @user275587: That's true, but if your cells form what is essentially a grid, or simply have the same width, it won't be an issue. – Eric Mickelsen Jun 14 '10 at 16:02