SnapsToDevicePixel does not work VS2008/Wpf .net 3.0

R

Rolf Welskes

Hello,
I have the following problem.
Here the xaml:

<Window x:Class="PixelSnappingtest01.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="476">
<Grid Background="LightGray">
<StackPanel Width="150" Background="White" Margin="29,12,0,0"
Orientation="Horizontal" Height="100" HorizontalAlignment="Left"
VerticalAlignment="Top">
<!-- Single pixel line with pixel snapping turned OFF.-->
<Rectangle SnapsToDevicePixels="False"
Width="30" Margin="10.5" Height="45.5" Fill="White" Stroke="Red"
StrokeThickness="1"/>
<!-- Single pixel line with pixel snapping turned ON.-->
<Rectangle SnapsToDevicePixels="True"
Width="30" Margin="10.5" Height="45.5" Fill="White" Stroke="Red"
StrokeThickness="1"/>
</StackPanel>
<StackPanel Background="White" Margin="29.5,0,0,47"
Orientation="Horizontal" Height="70" VerticalAlignment="Bottom"
HorizontalAlignment="Left" Width="149.5">
<!-- Single pixel line with pixel snapping turned OFF.-->
<Polyline SnapsToDevicePixels="False"
Width="45.5" Margin="10" Height="30" Stroke="Red" StrokeThickness="1"
Points="5,5 25,5 25,25 50,25"
/>
<Polyline SnapsToDevicePixels="True"
Width="45.5" Margin="10.5" Height="30" Stroke="Red"
StrokeThickness="1"
Points="5,5 25,5 25,25 50,25"
/>
</StackPanel>
</Grid>
</Window>
In the first part I have a line drawn using a Rectangle one time
SnapsToDevicePixel = false then true.
Works fine.
In the second Part I have a PolyLine. One one time SnapstoDevicePixel false,
then true.
Does not work.
Means: SnapsTo DevicePixel works for PolyLine, BUT: the PolyLine is not 1
pixel but 2 pixel in thickness.
That is the problem, I need it 1 pixel in thickness.

Thank you for any help.
best Regards
Rolf Welskes
 
C

cwavnew

I have the same problem. If I set SnapsToDevicePixels to true if I draw
single lines it works fine. If I make a PathGeometry of the same single
lines (or StreamGeometry) then the pixels do NOT snap. All the lines are
purely horizontal and vertical.

Is there anyway around this?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top