views:

179

answers:

3

If I zoom large enough in xamlpadx (500%) I see while lines around the inside of the border. In my app this even happens at normal zoom level in some controls.

Why is that and more important, what can I do about it?

This is my XAML code:

<Border Background="#000000" BorderBrush="#000000" BorderThickness="4" CornerRadius="4">    
   <StackPanel>               
   </StackPanel>
</Border>

I removed everything until I was sure that no padding/margin/border is involved in the flawed display.

EDIT 2: I shouldn't have accepted the answer so soon. I noticed that in same cases the error is as before, although I used SnapsToDevicePixels and set the interior color of the control to the same color as the border. I hope microsoft will fix this soon!

+5  A: 

I have the same behavior and I think that it is an error of the WPF rendering engine. You get slightly better results by adding SnapsToDevicePixels="True" to the Border: the white lines remain only in the rounded corners.

Mart
+1  A: 

This indeed seems a bug in WPF. However for your specific case you can use two workarounds:

<Border Background="#000000" BorderThickness="0" CornerRadius="4">
   <StackPanel Margin="4">               
   </StackPanel>
</Border>

Or

<Border Background="#000000" BorderThickness="0" CornerRadius="4">
   <Border Background="#000000" BorderThickness="0" CornerRadius="4" Margin="4">
       <StackPanel>               
       </StackPanel>
    </Border>
</Border>
Julien Lebosquain
This didn't help either
codymanix
+1  A: 

This behavior is inherent in the way WPF works. It's not a bug. Note that your coordinates are all doubles, not integers: These are not precise units. If you zoom in enough, you will see errors.

The following is from memory from about a year ago, but I think it's right:

If you're drawing to the wpf rendering context by hand, you can use the 'guidelines' system to make things line up. This is how the buttons and things are drawn for the stock UI styles. Take a look at the reference source (http://blogs.msdn.com/rscc/default.aspx) and you can see for yourself. There's also a good msdn page on this subject in general: http://msdn.microsoft.com/en-us/library/aa970908.aspx

Russell Mull
But where can white lines come from even if the background of the control is also black?
codymanix
I have no idea. Very curious.
Russell Mull