奇怪的行为MetroAnimatedSingleRowTabControl

时间:2016-01-25 12:16:55

标签: wpf mahapps.metro

我在MetroAnimatedSingleRowTabControl中发现了一个奇怪的行为。渲染看起来与使用“普通”TabControl不同(更像是像素化)。

试试

<controls:MetroWindow  x:Class="WpfApplication1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
    xmlns:wpfApplication1="clr-namespace:WpfApplication1"
    xmlns:system="clr-namespace:System;assembly=mscorlib"

    Title="MainWindow" >

<StackPanel>
    <controls:MetroAnimatedSingleRowTabControl>

        <controls:MetroAnimatedSingleRowTabControl.Items>
            <system:String>My string</system:String>
            <system:String>My string2</system:String>
            <system:String>My string3</system:String>
        </controls:MetroAnimatedSingleRowTabControl.Items>
        <controls:MetroAnimatedSingleRowTabControl.ItemContainerStyle>
            <Style TargetType="TabItem">
                <Setter Property="Header" Value="{Binding}" />
            </Style>
        </controls:MetroAnimatedSingleRowTabControl.ItemContainerStyle>

        <TabControl.ContentTemplate>
            <DataTemplate>
                <StackPanel>
                    <TextBlock Text="{Binding}" FontSize="10"></TextBlock>
                    <TextBlock Text="{Binding}" FontSize="20"></TextBlock>
                    <TextBlock Text="{Binding}" FontSize="30"></TextBlock>
                    <TextBlock Text="{Binding}" FontSize="40"></TextBlock>
                </StackPanel>

            </DataTemplate>
        </TabControl.ContentTemplate>

    </controls:MetroAnimatedSingleRowTabControl>

    <TabControl>

        <TabControl.Items>
            <system:String>My string</system:String>
            <system:String>My string2</system:String>
            <system:String>My string3</system:String>
        </TabControl.Items>
        <TabControl.ItemContainerStyle>
            <Style TargetType="TabItem">
                <Setter Property="Header" Value="{Binding}" />
            </Style>
        </TabControl.ItemContainerStyle>

        <TabControl.ContentTemplate>
            <DataTemplate>
                <StackPanel>
                    <TextBlock Text="{Binding}" FontSize="10"></TextBlock>
                    <TextBlock Text="{Binding}" FontSize="20"></TextBlock>
                    <TextBlock Text="{Binding}" FontSize="30"></TextBlock>
                    <TextBlock Text="{Binding}" FontSize="40"></TextBlock>
                </StackPanel>

            </DataTemplate>
        </TabControl.ContentTemplate>

    </TabControl>


</StackPanel>

Example

有人知道如何解决这个问题吗?

提前致谢

1 个答案:

答案 0 :(得分:1)

问题在于内部RenderOptions.ClearTypeHintTextOptions.TextFormattingModeTransitioningContentControl的设置。

作为一种解决方法,您可以在需要的地方覆盖它。

<StackPanel>
    <StackPanel.Resources>
        <Style BasedOn="{StaticResource {x:Type Controls:TransitioningContentControl}}" TargetType="{x:Type Controls:TransitioningContentControl}">
            <Setter Property="RenderOptions.ClearTypeHint" Value="Auto" />
            <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
        </Style>
    </StackPanel.Resources>
    <Controls:MetroAnimatedSingleRowTabControl>

        <Controls:MetroAnimatedSingleRowTabControl.Items>
            <system:String>My string</system:String>
            <system:String>My string2</system:String>
            <system:String>My string3</system:String>
        </Controls:MetroAnimatedSingleRowTabControl.Items>

        <TabControl.ContentTemplate>
            <DataTemplate>
                <StackPanel>
                    <TextBlock FontSize="10" Text="{Binding}" />
                    <TextBlock FontSize="20" Text="{Binding}" />
                    <TextBlock FontSize="30" Text="{Binding}" />
                    <TextBlock FontSize="40" Text="{Binding}" />
                </StackPanel>
            </DataTemplate>
        </TabControl.ContentTemplate>

    </Controls:MetroAnimatedSingleRowTabControl>

    <TabControl>

        <TabControl.Items>
            <system:String>My string</system:String>
            <system:String>My string2</system:String>
            <system:String>My string3</system:String>
        </TabControl.Items>

        <TabControl.ContentTemplate>
            <DataTemplate>
                <StackPanel>
                    <TextBlock FontSize="10" Text="{Binding}" />
                    <TextBlock FontSize="20" Text="{Binding}" />
                    <TextBlock FontSize="30" Text="{Binding}" />
                    <TextBlock FontSize="40" Text="{Binding}" />
                </StackPanel>
            </DataTemplate>
        </TabControl.ContentTemplate>

    </TabControl>
</StackPanel>

enter image description here

希望这有帮助!