views:

189

answers:

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?

+1  A: 

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: http://stackoverflow.com/questions/606220/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"

Eric Mickelsen
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.
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: 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