Click here to Skip to main content
16,016,623 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Inside <window> tag, I have written below code
C#
<Grid Width="80" Height="80" Background="LightGoldenrodYellow">
        <Polygon Points="0,0 80,80"
                 StrokeThickness="1"
                 Stroke="Black" />
    </Grid>
I am trying to draw line using Polygon control in place of Line or Polyline control. If we see design view of the form, then Polygon has started from upper left point of the Grid and ended at lower right point of Grid. It is fine. But

If inside <window> tag, I have written below code
C#
<Canvas Width="80" Height="80" Background="LightGoldenrodYellow">
        <Polygon Points="0,0 80,80"
                 StrokeThickness="1"
                 Stroke="Black" />
    </Canvas>
Polygon has started some distance before the upper left point of Canvas and ended some distance after the lower right point of Canvas. This line goes outside of the Canvas control. Why is it happening?

What I have tried:

I have searched this issue on internet, but I have not found any link related to this issue.
Posted
Comments
[no name] 29-Mar-23 11:34am    
Canvas is "virtual"; it's only (real) function is to provides an origin for the controls within (on) it; it doesn't restrict them.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900