2012-07-08 70 views
0

我正在使用XAML和C#开发metroapp,并且我使用的是本地化,其中文本是动态的,并且因语言而异。我的代码结构如下 - Border中的TextBlock。根据文本大小的边框高度

<Border> 
     <TextBlock Text="Foo"> 
     </TextBlock> 
</Border> 

那么有什么方法可以根据文本的大小来改变边框或文本块的高度和宽度吗?

请帮帮我。在此先感谢

回答

0

做了什么这样的:(测试很快,应该工作)

    <Border BorderBrush="AliceBlue" Background="SlateBlue" Width="{Binding ElementName=tb, Path=ActualWidth}" Height="{Binding ElementName=tb, Path=ActualHeight}"> 
         <TextBlock FontSize="45" Name="tb" Text="12345" Foreground="AliceBlue"/> 
        </Border> 
0

检查ActualHeightActualWidthFrameworkElement类的属性,TextBlock类从中继承。

0

包装它StackPanel应该工作。

相关问题