How to resize a Canvas in WPF?

后端 未结 3 1592
渐次进展
渐次进展 2021-01-19 06:58

I\'m writing a WPF app that has a Canvas in it. This canvas will be custom rendered at runtime. It\'s sort of like a game in that it needs to be measured in pix

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-19 07:42

    resizing is cake:

    MyCanvas.Width = 350;
    MyCanvas.Height  = 450;
    

    this sets the size, you CAN render to coordinates outside of this, but it will be clipped. You can wrap your canvas inside a scroller to allow the user to see what is outside the height/width of the canvas.

    as for the rest of your questions, i think you can see this SO question for your answers

提交回复
热议问题