简体   繁体   中英

WPF Rotated TextBlock look unclear

I have a Expander with a TextBlock assigned to the Header. It's rotated 90 degrees. The problem is that the Text look unclear:

字体不清楚

As you can see the "Debug" isn't that sharp! Is there a way to fix it?

MY XAML code is

<Window x:Class="Minecraft_Autocarafter.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
<Grid Margin="10,10,10,10">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="220*"/>
        <ColumnDefinition Width="277*"/>
    </Grid.ColumnDefinitions>

    <Button Name="RunButton"  Content="Run Bot" Click="RunButton_Click" HorizontalAlignment="Left" Width="80" Height="23" VerticalAlignment="Top"/>
    <Button x:Name="StopButton"  Content="Stop Bot" Click="StopButton_Click" HorizontalAlignment="Left" Width="80" Height="23" VerticalAlignment="Top" Margin="0,28,0,0" IsEnabled="False"/>
    <ListBox x:Name="AblaufBox" Margin="100,0,0,0" HorizontalAlignment="Left" Width="100">
        <ListBoxItem Content="Started"/>
        <ListBoxItem Content="Checking Items"/>
        <!--<ListBoxItem Name="Start" Content="Started"/>
        <ListBoxItem Name="Start" Content="Started"/>-->
    </ListBox>



    <Expander Grid.Column="1" Margin="10,0,17,0" ExpandDirection="Right">
        <Expander.Header>
            <TextBlock Text="Debug">
                <TextBlock.RenderTransform>
                    <TransformGroup>
                        <RotateTransform Angle="90"/>
                        <TranslateTransform X="25"/>
                    </TransformGroup>
                </TextBlock.RenderTransform>
            </TextBlock>
        </Expander.Header>
        <Grid Grid.Column="1" Visibility="Visible">
            <ListBox Name="DebugListBox">
                <ListBoxItem Content="Test"/>
            </ListBox>
        </Grid>
    </Expander>
</Grid>

Oh, and I started WPF one hour before, so don't flame me please :D

Try this

 <Expander Grid.Column="1" Margin="10,0,17,0" ExpandDirection="Right">
        <Expander.Header>
            <TextBlock Text="Debug" TextOptions.TextFormattingMode="Display">
            </TextBlock>
        </Expander.Header>
 </Expander>

please refer this link

Try setting properties for TextBlock :

UseLayoutRounding="True" OR SnapsToDevicePixels="True" 
TextOptions.TextFormattingMode="Display"
TextOptions.TextRenderingMode="ClearType"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM