如何在Silverlight +填充中使用自动宽度/高度获取文本元素周围的边框

时间:2010-10-20 21:59:07

标签: silverlight border padding

我目前所拥有的只是宽度:

<Grid>
        <Rectangle Fill="#FFF5F7F9" HorizontalAlignment="Left" Height="80" Stroke="#FF565656" VerticalAlignment="Top" Width="128" RadiusY="15" StrokeThickness="3" RadiusX="15"/>
        <TextBlock HorizontalAlignment="Left" Height="47" TextWrapping="Wrap" Text="Draft" VerticalAlignment="Top" Width="106" FontSize="32" FontStyle="Italic" FontFamily="Verdana" Margin="20,21,0,0"/>
</Grid>

等同于html的东西(仅举例):

<div style="display:inline;border:solid 3px #000;padding:3px">
   Some text here
</div>

1 个答案:

答案 0 :(得分:1)

发现它......为这个非常棒的问题而烦恼。

<Border
            BorderThickness="2"
            BorderBrush="Black"
            Background="AliceBlue"
            HorizontalAlignment="Left"
            VerticalAlignment="Top" Padding="10">

                <TextBlock>Hello World!</TextBlock>

        </Border>