簡體   English   中英

如何通過保持自動調整大小功能在WPF中旋轉文本

[英]How to rotate Text in WPF by keeping the Auto-Sizing function

我要垂直輸入文字。 我只是在WPF中使用簡單的網格來自動調整區域大小。 但是,當使用RotateTransform ,所有計算都是錯誤的。 任何想法如何解決這個問題?

        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

WPF旋轉文字 在此圖像中,您會明白我的意思。 如果現在我要自動調整中間部分的大小,則不能使用“ Width”或“ Height”屬性,因為兩者都會導致錯誤的尺寸調整結果。 Width = 120px將增加水平(原始)寬度,並使整個行變為120pixel。 Height = 120px將使文本高度為120pixel。

使用LayoutTransform而不是RenderTransform 它在布局過程中而不是在渲染過程中應用。

就像Rachel所說的,使用LayoutTransform

<TextBlock Text="Goodday" >
   <TextBlock.LayoutTransform>
     <RotateTransform Angle="90" />
   </TextBlock.LayoutTransform>  
</TextBlock>
<TextBlock Height="14" 
    x:Name="TextBlock1" 
    Text="Vertical Bottom to Up" Margin="73,0,115,0" RenderTransformOrigin="0.5,0.5" > 
    <TextBlock.RenderTransform> 
        <TransformGroup> 
            <ScaleTransform/> 
            <SkewTransform/> 
            <RotateTransform Angle="-90"/> 
            <TranslateTransform/> 
        </TransformGroup> 
    </TextBlock.RenderTransform> 
</TextBlock> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM