Horizontal or vertical WPF Lines limited to 125,000 pixels?

后端 未结 2 1874
慢半拍i
慢半拍i 2021-01-18 12:30

Are horizontal or vertical WPF Lines limited to 125,000 pixels? Looking at the following code the Green line displays correctly but the Red one does not display at all despi

相关标签:
2条回答
  • 2021-01-18 12:36

    This seems to be a limitation in WPF's handling of vector graphics.

    To make it more complicated, try changing the StrokeThickness - if you set the StrokeThickness of your red line from 1 to 2, it displays again... until you increase the length above 250000.. Then it vanishes again.

    <Grid>
        <Line X1="0" X2="125000.00" Y1="10" Y2="10" StrokeThickness="1" Stroke="Green"></Line>
        <Line X1="0" X2="250000.00" Y1="20" Y2="20" StrokeThickness="2" Stroke="Red"></Line>
        <Line X1="0" X2="250000.01" Y1="30" Y2="30" StrokeThickness="2" Stroke="Blue"></Line>
    </Grid>  
    

    The max length goes up as you increase your stroke thickness.

    Also Note that if the line wasn't perfectly horizontal or vertical, the length limit seems to vanish:

    <Grid>
        <Line X1="0" X2="125000.00" Y1="10" Y2="10" StrokeThickness="1" Stroke="Green" />
        <Line X1="0" X2="125000.01" Y1="20" Y2="20.0001" StrokeThickness="1" Stroke="Red" />
    </Grid>
    

    You can find the bug written up on connect: Disappearing Path (WPF)

    0 讨论(0)
  • It definitely draws past 150,000 pixels, It is a bit strange that the line is not seen in this case, because for example if you do this

    <Line X1="0" X2="125000.01" Y1="20" Y2="20" StrokeThickness="2" Stroke="Red"></Line>
    

    or this

    <Line X1="0" X2="125000.01" Y1="21" Y2="20" StrokeThickness="1" Stroke="Red"></Line>
    

    all works fine, There is probably a answer somewhere as to why, but good find as this would cause significant flicker if you were animating the value of X2.

    0 讨论(0)
提交回复
热议问题