0

の色TabItemsが常に黒なのはなぜですか。Background白黒の文字が欲しいです。また、Button白のはずですが、黒すぎて見えません。いくつかの競合がありますが、場所が見つかりません。何か案は?あなたの助けのために前もってThx。

<UserControl x:Class="Test.Test"
         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" 
         xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
         xmlns:cal="http://www.caliburnproject.org"   
         xmlns:cm="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro"
         mc:Ignorable="d" d:DesignHeight="252" d:DesignWidth="894" Background="#FF111111">    

<Grid>        
    <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top" Foreground="White" FontSize="48" Margin="70,-14.668,0,0" FontWeight="Light"><Run Language="de-at" Text="test test"/></TextBlock>
    <Button x:Name="Close" Content="➔" HorizontalAlignment="Left" VerticalAlignment="Top" Width="58" Foreground="White" Height="58" RenderTransformOrigin="0.5,0.5" FontSize="40" Margin="-7.625,-8,0,0" Padding="1,-5,1,1" Clip="M50.333,8 L-1.667,8 L-1.667,59.843 L50.333,59.843 z" cm:Message.Attach="Close()">
        <Button.RenderTransform>
            <TransformGroup>
                <ScaleTransform ScaleY="1" ScaleX="-1"/>
                <SkewTransform AngleY="0" AngleX="0"/>
                <RotateTransform Angle="0"/>
                <TranslateTransform/>
            </TransformGroup>
        </Button.RenderTransform>
    </Button>

    <TabControl Margin="42,52,0,0">
        <TabItem Header="Start">

        </TabItem>
            <TabItem Foreground="White" Header="Start 1" >

        </TabItem>
        <TabItem Foreground="White" Header="Start 1">

        </TabItem>
        <TabItem Foreground="White" Header="Start 1">

        </TabItem>
        <TabItem Foreground="White" Header="Start 1">

        </TabItem>
    </TabControl>       
</Grid>

私は多くのことを試しましたが、うまくいきませんでした。だから私がしたことは、のTextBlock中に入れましたTabItem.Header

<TabItem>
    <TabItem.Header>
        <TextBlock FontSize="25" Text="Start1" />
    </TabItem.Header>
</TabItem>

の色を変更できるようになりTextBlockましたForegroundTextBlockしかし、 をクリックすると色を変更する方法がわかりませんTabItem。そのための新しいトピックを開く必要があるかもしれません。あなたの貢献に感謝します。

4

1 に答える 1

1

BackgroundまたはForegroundプロパティをまったく設定していないTabControlため、デフォルトの色を使用しています。

オブジェクトのBackgroundプロパティのデフォルトの色は( source ) ですが、デフォルトのプロパティはシステムの色 ( source )に基づいています。ControlBrushes.TransparentForeground

すべての Control オブジェクトにこのスタイルを使用するなど、暗黙的なスタイルを使用してUserControl.Resources、指定された型のすべてのオブジェクトにプロパティを設定できます。

<UserControl.Resources>
    <Style TargetType="{x:Type Control}">
        <Setter Property="Background" Value="Black" />
        <Setter Property="Foreground" Value="White" />
    </Style>
</UserControl.Resources>

または、新しい Brush を追加してSystemColorsのいずれかの System Key に.Resources設定できる場合は、次のようになります。x:Key

<UserControl.Resources>
    <SolidColorBrush x:Key="{x:Static SystemColors.WindowColorKey}" Color="Black"/>
    <SolidColorBrush x:Key="{x:Static SystemColors.ControlTextBrush}" Color="White"/>
</UserControl.Resources>

(使用する正しい SystemColors キーを特定するために、少しテストする必要があるかもしれません。それらのリストは、ここで見つけることができます) 。

于 2013-01-25T14:37:56.907 に答える