Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Canvas Horizontal Line Background is antialiased

$
0
0

Hello together,

I have a Problem using a VisualBrush Tile Background on a Canvas.

I want to draw horizontal and vertical helplines in black Color. But all the time, the lines are antialiased (the vertical is 1 pixel wide but gray and the horizontal line is 2px high and also gray / light gray). If I copy in the Lines to the Childrens of Canvas, it is displayed clear in real black color and only 1 pixel wide.

I have following Source Code.

<Canvas Width="800" Height="400" SnapsToDevicePixels="True"><Canvas.Background><VisualBrush TileMode="Tile" Viewport="0,0,20,20" ViewportUnits="Absolute" Viewbox="0,0,20,20" ViewboxUnits="Absolute"><VisualBrush.Visual><Grid><Line X1="0" Y1="0" X2="0" Y2="20" Stroke="Black" StrokeThickness="1" /><Line X1="0" Y1="0" X2="20" Y2="0" Stroke="Black" StrokeThickness="1" /></Grid></VisualBrush.Visual></VisualBrush></Canvas.Background><Canvas.Children><Line X1="50" Y1="50" X2="80" Y2="50" Stroke="Black" StrokeThickness="1" /><Line X1="50" Y1="50" X2="50" Y2="80" Stroke="Black" StrokeThickness="1" /></Canvas.Children></Canvas>

We use .NET 4.0.

Can you please help me how to solve this problem to get really black and clear lines in Background?

Thank you.

Kind regards
Stefan


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>