tags:

views:

595

answers:

2

I have a Grid in WPF. The Grid has a transparent background (necessary) and each of the cells potentially has a different colored solid background, or maybe no background. When I put arbitrary content in these cells, when two adjacent cells both have colored backgrounds (same or different color, it doesn't matter) there is often (and unpredictably) a thin transparent line separating them, allowing you to see through the grid at that line.

Does anyone know how this could possibly be fixed?

Edit: Meant to mention it in my question, but I've tried enabling SnapsToDevicePixels anywhere and everywhere I can, to no avail.

+1  A: 

Without seeing any code my guess is that you need SnapsToDevicePixels on the elements in the grid.

Todd White
I had this same issue too... if that works... rock on!
Timothy Khouri
Meant to mention it in my question, but I've tried enabling SnapsToDevicePixels anywhere and everywhere I can, to no avail.
Daniel Jennings
Can you provide a sample of that code?
Todd White
Ugh, I tried to write a sample but it doesn't capture the problem so I'll have to try to get more out from the "real" application to write a sample.
Daniel Jennings
Can you pin it down to particular cell content? Does forcing a redraw (minimise etc) remove the issue? Is it possible you accidentally have an empty column/row at that point?
Donnelle
I see the problem when one of the cells has content that varies. This is in a subclassed Window, and you can set the Content of one specific cell. Different sizes of Content (which stretch the cell and window) cause different lines to appear.
Daniel Jennings
Appears when going bigger, or only when going smaller?
Donnelle
And star or auto sizing?
Donnelle
Ooh, I have a sample that can reproduce what I think is the same issue. Will post it in a new answer in a few ticks.
Donnelle
+1  A: 
Donnelle
That's very similar to an approximation I tried, but this problem is solved via adding SnapsToDevicePixels=true on all of the elements (not sure where exactly it's necessary, so I put it on everything even though I think it trickles down.) I swear I have the problem even with SnapsToDevicePixels on.
Daniel Jennings
Interesting-- I put SnapsToDevicePixels on the window, the grid, all the labels, the buttons and the TextBlock, and I still get those lines. What size-related properties are you using on the window? (SizeToContent etc).
Donnelle
You could hack it by making the margins on the content -1. But I hate that. :(
Donnelle
The window is SizeToContent="WidthAndHeight". I'll try the Margins technique just for the hell of it.
Daniel Jennings
Did the margins fix it?
Donnelle