【问题标题】:wpf textblock text is not clear when using layouttransform使用layouttransform时wpf textblock文本不清晰
【发布时间】:2011-08-01 09:09:26
【问题描述】:

我正在使用 TextBlock 控件。 TextBlock 中的文本以 0 度旋转清晰显示。

但是,如果我使用 LayoutTransform 将控件旋转到 90 度,则文本不清楚。一些模糊的显示。

有没有其他方法可以在没有 LayoutTransform 的情况下旋转文本或任何其他方式来清晰显示?

【问题讨论】:

    标签: wpf layouttransform


    【解决方案1】:

    尝试在您的 TextBox 上使用“UseLayoutRounding=true”

    【讨论】:

    • 我没有找到像 UseLayoutRounding=true 这样的属性。我正在使用 TextBlock 控件。
    • UseLayoutRounding 属性将在父控件(面板)中可用,为文本框父级设置该属性,如网格、画布、包装面板、堆栈面板
    • 我当前的项目使用的是 FrameWork 3.5。 UseLayoutRounding 选项适用于 FrameWork 4.0
    • 我当前的项目使用的是 FrameWork 3.5。 UseLayoutRounding 选项适用于 FrameWork 4.0
    • arf.那你就卡住了。
    【解决方案2】:

    我知道这是一个老问题,但是,我在使用 SnapsToDevicePixels="True" 和 UseLayoutRounding="True" 的用户控件时遇到了同样的问题 第一个标签下方的代码显示了一个模糊的框,而未转换的则完美地显示了文本。我尝试将快照和舍入属性向上传递到层次结构,最后,修复此行为的唯一方法是将 UseLayoutRounding="True" 应用于窗口。将其应用于任何其他子面板或用户控件并不能解决此问题。

        <UserControl x:Class="MyApp.Controls.Indications"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
             SnapsToDevicePixels="True"
             UseLayoutRounding="True">
        <Stackpanel>
    
        <Label
            BorderBrush="Black"
            BorderThickness="1"
            HorizontalAlignment="Center">
    
            <TextBlock
                Width="100"
                TextAlignment="Center"
                Text="Left Outboard Actuator"
                TextWrapping="Wrap">
    
                <TextBlock.LayoutTransform>
                    <RotateTransform
    
                        Angle="90"/>
                </TextBlock.LayoutTransform>
    
            </TextBlock>
    
        </Label>
    
        <Label
            BorderBrush="Black"
            BorderThickness="1"
            HorizontalAlignment="Center">
    
            <TextBlock
                Width="100"
                TextAlignment="Center"
                Text="Left Outboard Actuator"
                TextWrapping="Wrap">
    
            </TextBlock>
    
        </Label>
    
        </Stackpanel>
    </UserControl>
    

    【讨论】:

      【解决方案3】:

      设置 TextBlock 的 Foreground 属性值(如 Black)将被清除。当我将文本块旋转 90 度时,它对我的​​项目有效。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-01-20
        • 2013-01-15
        • 2016-06-19
        • 1970-01-01
        • 2019-02-09
        相关资源
        最近更新 更多