question

TrnBoDng-2128 avatar image
0 Votes"
TrnBoDng-2128 asked ·

[WPF] Some paths was disappeared when scale canvas

When I add many Paths on canvas and zoom out canvas, some paths was disappeared.

I execute on Window 10, 64 bit and .Net 4.7

Please let me know, why some paths was disappeared and solution for this issue.

Thank you so much!

windows-wpf
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

AlexLi-MSFT avatar image
0 Votes"
AlexLi-MSFT answered ·

Hi,

Welcome to our Microsoft Q&A platform!

You can add a Viewbox to the outermost layer of the Canvas.

 <Viewbox>
             <Canvas Width="400" Height="200" Name="canva">
                 ...
             </Canvas>
         </Viewbox>

Thanks.

· 4 · Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Dear AlexLi-MSFT

Thank for your answer, but it isn't good in my case.

Code add rectangle into canvas below:

 p = new Path();
    
 p.Stroke = Brushes.Black;
    
 p.Fill = Brushes.Transparent;
    
  RectangleGeometry rectangleGeometry = new RectangleGeometry(new Rect(20, 20, 200, 20));
    
  p.Data = rectangleGeometry;
    
  p.StrokeThickness = 0.13;


6911-after.png






0 Votes 0 · ·
after.png (72 B)

You can fix your code p.StrokeThickness = 1,then test your code.

0 Votes 0 · ·

p.StrokeThickness = 1 is worked, but I don't want to change StrokeThickness so much.

Please let me know, the minimum value StrokeThickness when scale canvas.

0 Votes 0 · ·
Show more comments