I want to draw rectangle by two triangles. Very simple task. But Silverlight can't handle it.
<Grid x:Name="LayoutRoot" UseLayoutRounding="False" Background="White">
<Polygon Fill="Black">
<Polygon.Points>
<Point X="10" Y="100"/>
<Point X="100" Y="10"/>
<Point X="100" Y="100"/>
</Polygon.Points>
</Polygon>
<Polygon Fill="Black">
<Polygon.Points>
<Point X="10" Y="10"/>
<Point X="100" Y="10"/>
<Point X="10" Y="100"/>
</Polygon.Points>
</Polygon>
</Grid>
Logicly i have to see a rectangle when i compile this code. If you try to use this code you will see the rectangle but you will have an annoing white line in it...
So i whant to know.. is there a way to draw rectangle (that will look like rectangle) by two triangles in Silverlight?
Have you checked
Stroke
andStrokeThickness
properties? I'm not sure they have by default values which will allow you to draw a rectangle without any space between triangles.UPDATE will this help you?
Add .5 to the points on the connecting side. Silverlight is a little wierd about edges. Look at the edges of the rectangle and see if they look grey or solid black. You might have to adjust some .5's to fix that too.
This is a little verbose in Xaml, but if you're creating the triangles programatically it shouldn't matter, how about something like this:
This way you're really compositing a single element, the Path, with triangles. The way you've shown creates separate elements and each are going to be anti-aliased individually.
Hope that helps.
Sergio