Resizing canvas items

前端 未结 3 1739
Happy的楠姐
Happy的楠姐 2021-01-24 15:07

I\'m trying to create canvas which resizes its children when canvas itself is resized. So I create my own class which inherits from canvas and overrides method ArrangeOverride w

3条回答
  •  伪装坚强ぢ
    2021-01-24 15:23

    This may or may not exactly fit your requirements, but whenever I hear/read 'resize', I think of the UI control that was built just for that purpose; the Viewbox. Using this class, you have several options over how the content should be resized, but I think that you would want the default Uniform method.

    Just put whatever you need to be resized into a ViewBox and see how you like it... it should do the job nicely and simply for you:

    
        
    
    

    You don't actually need to add the Stretch="Uniform" here because that is the default... it's just here for demonstration purposes. To find out more, please see the Viewbox Class page on MSDN.

提交回复
热议问题