In Silverlight and WPF, is ther开发者_高级运维e a default height for a TextBlock and if so, what is it?
<Grid x:Name="LayoutRoot" Background="White">
<Border BorderBrush="Blue" BorderThickness="1" CornerRadius="5">
<TextBlock x:Name="Itself" Text="{Binding ElementName=Itself, Path=ActualHeight}" />
</Border>
</Grid>
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).
it is 23 in VS2008. But that is not so difficult to find out...
It is not a true control but a frameworkelement. Hence it's default height is the same as the control within which it is kept.
精彩评论