Sunday, 18 August 2013

How to force smooth rendering of WPF Controls?

How to force smooth rendering of WPF Controls?

I am creating a simple WPF Application, which should combine a couple of
images within a scrollable area. These images should have absolutely no
border, which should be no problem when simply positioning them correctly.
When I start the application, everything is rendered as intended. But when
I start scrolling some (white) borders between the images occur. (See
Screenshot)

I think the same problem would occur, when i start zooming/scaling inside
the ScrollViewer.
So my question is, how to avoid such borders, wihtin a WPF application and
especially within a ScrollViewer?
The following code should be enough to reproduce the problem:
<Window x:Class="Test.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<ScrollViewer HorizontalAlignment="Stretch" Name="scrollViewer1"
VerticalAlignment="Stretch" VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Auto">
<Grid>
<Grid Background="Black" Width="500" Height="500"
VerticalAlignment="Top" HorizontalAlignment="Left"/>
<Grid Background="Black" Width="500" Height="500"
Margin="500,0,0,0" VerticalAlignment="Top"
HorizontalAlignment="Left"/>
<Grid Background="Black" Width="500" Height="500"
Margin="500,500,0,0" VerticalAlignment="Top"
HorizontalAlignment="Left"/>
<Grid Background="Black" Width="500" Height="500"
Margin="0,500,0,0" VerticalAlignment="Top"
HorizontalAlignment="Left"/>
</Grid>
</ScrollViewer>
</Grid>

No comments:

Post a Comment