c# - TabControl 项目标题文本在旋转选项卡后显得模糊

标签 c# wpf xaml .net-4.0

我需要创建一个选项卡向左旋转的 WPF TabControl 控件。

我在网上找到的资源表明,这可以通过将以下两项应用于 TabControl 来完成:

<Setter Property="LayoutTransform">
   <Setter.Value>
     <RotateTransform Angle="270"/>
   </Setter.Value>
</Setter>

<TabControl TabStripPlacement="Left" ...


所有这一切都有效,选项卡按要求显示,但由于某种原因,选项卡中的标题文本在旋转后显得模糊,请说明为什么会发生这种情况,如果有什么我可以做的来解决这个问题。

完整的 XAML:

<Window x:Class="WpfApplication2.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>
        <TabControl BorderBrush="Gray" BorderThickness="1" TabStripPlacement="Left">
            <TabControl.ItemContainerStyle>
                <Style TargetType="{x:Type TabItem}">
                    <Setter Property="LayoutTransform">
                        <Setter.Value>
                            <RotateTransform Angle="270"/>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="Template">
                        <Setter.Value>                            
                            <ControlTemplate TargetType="{x:Type TabItem}">
                                <Grid>
                                    <Border Name="Border" BorderBrush="Gray" BorderThickness="1" CornerRadius="6,6,0,0">
                                        <ContentPresenter x:Name="ContentSite"
                                        VerticalAlignment="Center" HorizontalAlignment="Center" 
                                        ContentSource="Header" Margin="12,2,12,2"/>
                                    </Border>
                                </Grid>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </TabControl.ItemContainerStyle>
            <TabItem Header="Item 1" />
            <TabItem Header="Item 2" />
            <TabItem Header="Item 3" />
        </TabControl>
    </Grid>
</Window>

enter image description here

最佳答案

将以下属性添加到窗口声明 XAML

TextOptions.TextFormattingMode="Display"
TextOptions.TextRenderingMode="ClearType"
UseLayoutRounding="true"

关于c# - TabControl 项目标题文本在旋转选项卡后显得模糊,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12597474/

相关文章:

c# - C#/.NET (VS 2008) 到 Outlook (2007) 的问题

c# - 从通知导航

c# - 如何使用 WPF 和 MVVM 添加带有标题和内容的 TabItem

具有多选的 WPF TreeView

c# - 扩展 ContentView 时获取 "The name ' SomeName' does not exist in the current context"

c# - Bootstrap 类不能与 View 中的 HTML 控件一起使用

c# - 以编程方式从资源字典中添加删除项目

wpf - 为什么我的 TextBlock/TextBox 不应用来自基本样式的值?

silverlight - 绑定(bind)样式名称并更改样式 VIA View Model

wpf - 如何使用新项目更新 listView?