使用layouttransform时wpf文本块文本不清晰

发布于 2024-11-27 04:31:04 字数 168 浏览 4 评论 0原文

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

但如果我使用 LayoutTransform 将控件旋转到 90 度,文本将不清晰。显示有些模糊。

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

I am using TextBlock control. Text in the TextBlock is clearly displayed with 0 degree rotation.

But if i rotated the control to 90 degree using LayoutTransform, text is not clear. some blurry display.

Is there anyother way to rotate the text without LayoutTransform or anyother way for clear display?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

恋你朝朝暮暮 2024-12-04 04:31:04

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

try using "UseLayoutRounding=true" on your TextBox

才能让你更想念 2024-12-04 04:31:04

我知道这是一个老问题,但是,我对具有 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>

I know this is an old question, however, I had the same problem with a user control which had SnapsToDevicePixels="True" and UseLayoutRounding="True"
with the code below the first label showed a blurred box, while the non-transformed one showed the text perfectly. I tried flowing up the snaps and rounding properties up to the hierarchy and in the end, the only thing that fixed this behavior was to apply UseLayoutRounding=" True" to the window. Applying it to any other children panel or user-control did not fix it.

    <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>
颜漓半夏 2024-12-04 04:31:04

将 TextBlock 的 Foreground 属性设置一个值(如 Black)就会清晰。当我将文本块旋转 90 度时,它在我的项目中起作用。

Set TextBlock's Foreground property a value(like Black) will be clear. it's worked on my project when I rotate textblock 90 degree.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文