What is the default Height of a TextBlock?

前端 未结 3 1065
醉梦人生
醉梦人生 2021-01-21 08:07

In Silverlight and WPF, is there a default height for a TextBlock and if so, what is it?

3条回答
  •  长情又很酷
    2021-01-21 08:31

    
        
            
        
    
    

    Given the above XAML, with Silverlight 4, the TextBlock has a default fontsize of 11, and an ActualHeight of 16. The ActualHight shown in itself will be 0 due to the height being calculated too late.

    That's assuming you don't set them, in which case they won't be defaults.

    Interestingly, the exact same XAML in WPF, the height of the TextBlock fills the container it's in. In this case (for me anyway) it showed its own ActualHeight was 310. WPF didn't have the issue Silverlight had with binding to its own ActualHeight. Resizing the window changed the height. So in this case the default height could be said that its Auto (or NaN).

提交回复
热议问题