Windows phone 7 文本块旋转90度后被截断的文本
我有一个文本块,我想在一个30像素宽的用户控件中垂直显示。TextBlock控件已使用RenderTransform旋转90° 当我将它与30px的翻译结合起来时,旋转似乎发生得很好,但是TextBlock的实际内容被截断为30px 看起来文本以父对象的30像素宽度呈现,然后进行转换Windows phone 7 文本块旋转90度后被截断的文本,windows-phone-7,xaml,Windows Phone 7,Xaml,我有一个文本块,我想在一个30像素宽的用户控件中垂直显示。TextBlock控件已使用RenderTransform旋转90° 当我将它与30px的翻译结合起来时,旋转似乎发生得很好,但是TextBlock的实际内容被截断为30px 看起来文本以父对象的30像素宽度呈现,然后进行转换 <UserControl x:Class="Xyz.Controls.FooControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/p
<UserControl x:Class="Xyz.Controls.FooControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
d:DesignHeight="300" d:DesignWidth="30">
<Grid x:Name="LayoutRoot">
<Grid Name="barGrid" Background="#BFFFFFFF">
<Ellipse Width="30" Height="30" Fill="Red" HorizontalAlignment="Center" VerticalAlignment="Top" />
<TextBlock Name="barText" Text="88.8°"
Width="50"
Height="30"
Foreground="#FF3535C4">
<TextBlock.RenderTransform>
<CompositeTransform Rotation="90" TranslateX="30"/>
</TextBlock.RenderTransform>
</TextBlock>
</Grid>
</Grid>
</UserControl>
在VisualStudio的这个屏幕截图中,预期的文本仅显示29px。
Expression Blend和Emulator中也出现了同样的问题。我已经找到了一种获得预期布局的方法,但似乎有点麻烦 通过将文本块上的负左边距(-20px)设置为文本框宽度(50px)和父文本宽度(30px)之差,全文将垂直显示 例如
我不完全确定,但旋转文本的高度可能是屏幕方向的高度,因此30px会将其截断。不确定如何修复,这只是一个可能的原因。更改d:DesignWidth会直接更改垂直显示的文本量。例如,增加设计宽度会增加显示的文本量,反之亦然。这似乎对我的问题有效,但如果有人有更好的答案,我会将接受移到另一个位置。
<TextBlock Name="barText" Text="88.8°"
Width="50"
Height="30"
Foreground="#FF3535C4"
Margin="0,0,-20,0">
<TextBlock.RenderTransform>
<CompositeTransform Rotation="90" TranslateX="30"/>
</TextBlock.RenderTransform>
</TextBlock>