WPF TextBlock font resize to fill available space in a Grid

后端 未结 6 1507
醉酒成梦
醉酒成梦 2020-12-08 01:53

I have some text that is displayed at run time in a textblock. I want the font size to be the biggest it can be to fill the area that is given. I think I have the textblock

6条回答
  •  离开以前
    2020-12-08 02:27

    The WPF ViewBox control can grow / shrink with its contents to the available space.

    Just place your TextBlock within a ViewBox as;

    
        
    
    

    ViewBox is typically scaled by its container.

提交回复
热议问题