TextBlock as big as a capital letter (ignoring font ascender/descender)

前端 未结 2 1842
北恋
北恋 2021-01-02 18:44

I am looking to get a specific behavior on TextBlock so that its height only includes the height of the capital letters (from baseline to top minus \"ascender h

2条回答
  •  粉色の甜心
    2021-01-02 19:25

    Updated:

    If I understand right, there's a few tricks I know for this,

    You can Scale it with RenderTransform which is usually the most efficient way;

    
      
       
      
    
    

    Or you can embed the TextBlock in a Viewbox to "zoom" the text to fit the bounds of its container if for example you set hard height values on grid rows like;

    
    
    
    
    
    
          
          
    
    
          
          
    
    

    or you can bind the FontSize to a Container element like;

    
    
    
    

    They might present the effect you're after?

提交回复
热议问题