App.xaml中的样式'T显示一个福彩12选5走势图上的前景白色

Simsen.vejle.

成员
加入
2月14日,2021年
消息
21
编程经验
Beginner
除了一件事之外,我对福彩12选5走势图的福彩12选5走势图给了我一种风格。无论我在前景中设置了什么颜色,文本都是黑色的。

我尝试复制其他样式示例,说明前景是白色的。仍然是黑色的。我试图在福彩12选5走势图中制作一个标签,并为该标签白色制作前景。仍然是黑色的。我以为它可能有一些事情,即福彩12选5走势图在我的样式TabControl中,所以从选项卡外面拍摄了外部的福彩12选5走势图,但仍然是黑色的。所以现在我希望你们中的一个可以帮助我。

在观看设计师时显示纽扣文本但运行代码,它是黑色的。

UserControl accountView中的福彩12选5走势图

最好的祝福
Simsen.vejle.  :)


AccountView:
<UserControl xmlns:syncfusion="http://schemas.syncfusion.com/wpf"  x:Class="Views.Account.AccountView"
             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:local="clr-namespace:Views.Account"
             mc:Ignorable="d"
             d:DesignHeight="600" d:DesignWidth="1200">
    <Grid>
        <TabControl x:Name="tabAccountView">
            <TabItem Header="Platform">
                <!--<Button Content="Slet" Style="{StaticResource myButtonStyle}" />-->
                <Button Content="Slet" Foreground="White" />
            </TabItem>
            <TabItem Header="Miljø">
            </TabItem>
            <TabItem Header="Miljø Version">
            </TabItem>
            <TabItem Header="Komponent">
            </TabItem>
            <TabItem Header="Prioritet">
            </TabItem>
            <TabItem Header="Sværhedsgrad">
            </TabItem>
            <TabItem Header="Status">
            </TabItem>
            <TabItem Header="Kategori">               
            </TabItem>   
        </TabControl>       
    </Grid>
</UserControl>


具有样式的App.xaml:
<Application
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:AnsiBug"
             xmlns:syncfusion="http://schemas.syncfusion.com/wpf" x:Class="AnsiBug.App"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
        <!--#region Textblock -->
        <Style TargetType="{x:Type TextBlock}">
            <Setter Property="Foreground" Value="Black"/>
            <Setter Property="FontFamily" Value="Verdana" />
            <Setter Property="FontSize" Value="10" />
        </Style>
        <!--#endregion-->

        <!--#region Label -->
        <Style TargetType="{x:Type Label}">
            <Setter Property="Foreground" Value="Black"/>
            <Setter Property="FontFamily" Value="Verdana" />
            <Setter Property="FontSize" Value="10" />
        </Style>
        <!--#endregion-->

        <!--#region Textbox -->
        <Style TargetType="{x:Type TextBox}">
            <Setter Property="Foreground" Value="Black"/>
            <Setter Property="FontFamily" Value="Verdana" />
            <Setter Property="FontSize" Value="10" />
        </Style>
        <!--#endregion-->

        <!--#region Buttons -->

        <Style TargetType="{x:Type Button}">
            <Setter Property="Foreground" Value="White" />
            <Setter Property="FontFamily" Value="Verdana" />
            <Setter Property="FontSize" Value="10" />
            <Setter Property="Width" Value="122" />
            <Setter Property="HorizontalAlignment" Value="Center" />
            <Setter Property="HorizontalContentAlignment" Value="Center" />
            <Setter Property="VerticalContentAlignment" Value="Center" />
            <Setter Property="BorderThickness" Value="1" />
            <Setter Property="BorderBrush" Value="White" />
            <Setter Property="Height" Value="30" />
            <Setter Property="Padding" Value="15 15 15 15" />
            <Setter Property="Background" Value="#005b7f" />

            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                            <ContentPresenter x:Name="PART_Content"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          TextElement.Foreground="{TemplateBinding Foreground}"/>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="FontWeight" Value="Bold" />
                    <Setter Property="Background" Value="#5c99b1" />
                    <Setter Property="Foreground" Value="White" />
                </Trigger>
                <Trigger Property="IsMouseOver" Value="False">
                    <Setter Property="Foreground" Value="White" />
                </Trigger>
            </Style.Triggers>
        </Style>
        <!--#endregion-->
        
        <!--#region Top Menu knapper-->
        <Style TargetType="{x:Type Button}" x:Key="TopMenuButton">           
            <!--<Setter Property="Background" Value="White"/>-->
            <Setter Property="Foreground" Value="Black" />
            <Setter Property="FontFamily" Value="Verdana" />
            <Setter Property="FontSize" Value="12" />
            <Setter Property="Width" Value="122" />
            <Setter Property="HorizontalAlignment" Value="Left" />
            <Setter Property="HorizontalContentAlignment" Value="Left" />
            <Setter Property="VerticalContentAlignment" Value="Top" />
            <Setter Property="BorderThickness" Value="1" />
            <Setter Property="BorderBrush" Value="#005b7f" />
            <Setter Property="Height" Value="30" />
            <Setter Property="Padding" Value="15 15 15 15" />
            <Setter Property="ContextMenuService.IsEnabled" Value="False" />
            <Setter Property="ContextMenuService.Placement" Value="Bottom" />
            <Setter Property="ContextMenuService.PlacementTarget" Value="{Binding ElementName=BtnReports}" />
            <Setter Property="ContextMenuService.ShowOnDisabled" Value="False" />
            <Setter Property="Background">
                <Setter.Value>
                    <!--Øverste knap on mouse over-->
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="White" Offset="0.465"/>
                        <GradientStop Color="White" Offset="0.526"/>
                        <GradientStop Color="#005b7f" Offset="0.991"/>
                        <GradientStop Color="#005b7f" Offset="1"/>
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
            
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                            <ContentPresenter x:Name="PART_Content"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          TextElement.Foreground="{TemplateBinding Foreground}"/>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Background" Value="White" />
                    <Setter Property="FontWeight" Value="Bold" />
                    <Setter Property="Padding" Value="15 15 15 15" />
                    <Setter Property="Background">
                        <Setter.Value>
                            <!--Øverste knap on mouse over-->
                            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                <GradientStop Color="White" Offset="0.465"/>
                                <GradientStop Color="White" Offset="0.526"/>
                                <GradientStop Color="#005b7f" Offset="0.991"/>
                                <GradientStop Color="#005b7f" Offset="1"/>
                            </LinearGradientBrush>
                        </Setter.Value>
                    </Setter>
                </Trigger>
            </Style.Triggers>
        </Style>
        
        <!--#endregion-->

        <!--#region ContextMenu -->
        <Style TargetType="{x:Type ContextMenu}">
            <Setter Property="OverridesDefaultStyle" Value="True" />
            <Setter Property="SnapsToDevicePixels" Value="True" />
            <Setter Property="Foreground" Value="White" />
            <Setter Property="Width" Value="122" />
            <Setter Property="Placement" Value="Bottom" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ContextMenu}">
                        <Border BorderThickness="1" CornerRadius="4" BorderBrush="Black" x:Name="Border" Background="#005b7f">
                            <StackPanel ClipToBounds="True" Orientation="Vertical" IsItemsHost="True" Background="#005b7f" />
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="true">
                                <Setter TargetName="Border" Property="Background" Value="White" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style TargetType="{x:Type MenuItem}">
            <Setter Property="Foreground" Value="White" />
            <Setter Property="Margin" Value="-5,0,0,0" />
            <Setter Property="Height" Value="30" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type MenuItem}">
                        <Border x:Name="Border" Padding="10,5,10,5" BorderThickness="0" Margin="0">
                            <ContentPresenter ContentSource="Header" x:Name="HeaderHost" RecognizesAccessKey="True" />
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsHighlighted" Value="true">
                                <Setter Property="Background" TargetName="Border" Value="#5c99b1"/>
                                <Setter Property="Foreground" Value="White" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>           
        </Style>
        <!--#endregion-->

        <!--#region TabControl -->
        <Style TargetType="{x:Type TabControl}">
            <Setter Property="TabStripPlacement" Value="Left"/>
            <Setter Property="Width" Value="1120"/>
            <Setter Property="Height" Value="550"/>
            <Setter Property="HorizontalAlignment" Value="Left"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="FontFamily" Value="Verdana"/>
            <Setter Property="FontSize" Value="10"/>
            <Setter Property="BorderBrush" Value="Black"/>
            <Setter Property="BorderThickness" Value="1" />
        </Style>
        <Style TargetType="{x:Type TabItem}">
            <Setter Property="Background" Value="Black" />
            <Setter Property="FontFamily" Value="Verdana"/>
            <Setter Property="FontSize" Value="10"/>
            <Setter Property="Width" Value="110"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TabItem}">
                        <Grid>
                            <Border Name="Border"
                                    BorderThickness="1,1,1,1"
                                    CornerRadius="0,0,0,0"
                                    Height="40" BorderBrush="Black">
                                <ContentPresenter x:Name="ContentSite"
                                                  VerticalAlignment="Center"
                                                  HorizontalAlignment="Left"
                                                  ContentSource="Header"
                                                  Margin="12,2,12,2"
                                                  RecognizesAccessKey="True" />
                            </Border>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSelected" Value="True">
                                <Setter TargetName="Border" Property="Background" Value="#5c99b1" />
                                <Setter Property="Foreground" Value="White" />
                                <Setter Property="FontWeight" Value="ExtraBold" />
                            </Trigger>
                            <Trigger Property="IsSelected" Value="False">
                                <Setter TargetName="Border" Property="Background">
                                    <Setter.Value>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="White" Offset="0.465"/>
                                            <GradientStop Color="White" Offset="0.526"/>
                                            <GradientStop Color="#005b7f" Offset="0.991"/>
                                            <GradientStop Color="#005b7f" Offset="1"/>
                                        </LinearGradientBrush>
                                    </Setter.Value>
                                </Setter>
                            </Trigger>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Background" TargetName="Border" Value="#5c99b1"/>
                                <Setter Property="Foreground" Value="White"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style TargetType="{x:Type TabControl}" x:Key="tabControlSmall">
            <Setter Property="TabStripPlacement" Value="Left"/>
            <Setter Property="Width" Value="1120"/>
            <Setter Property="Height" Value="550"/>
            <Setter Property="HorizontalAlignment" Value="Left"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="FontFamily" Value="Verdana"/>
            <Setter Property="FontSize" Value="10"/>
            <Setter Property="BorderBrush" Value="Black"/>
            <Setter Property="BorderThickness" Value="1" />
        </Style>
        <Style TargetType="{x:Type TabItem}" x:Key="tabItemSmall">
            <Setter Property="Background" Value="Black" />
            <Setter Property="FontFamily" Value="Verdana"/>
            <Setter Property="FontSize" Value="10"/>
            <Setter Property="Width" Value="110"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TabItem}">
                        <Grid>
                            <Border Name="Border"
                                    BorderThickness="1,1,1,1"
                                    CornerRadius="0,0,0,0"
                                    Height="40" BorderBrush="Black">
                                <ContentPresenter x:Name="ContentSite"
                                                  VerticalAlignment="Center"
                                                  HorizontalAlignment="Left"
                                                  ContentSource="Header"
                                                  Margin="12,2,12,2"
                                                  RecognizesAccessKey="True" />
                            </Border>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSelected" Value="True">
                                <Setter TargetName="Border" Property="Background" Value="#5c99b1" />
                                <Setter Property="Foreground" Value="White" />
                                <Setter Property="FontWeight" Value="ExtraBold" />
                            </Trigger>
                            <Trigger Property="IsSelected" Value="False">
                                <Setter TargetName="Border" Property="Background">
                                    <Setter.Value>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="White" Offset="0.465"/>
                                            <GradientStop Color="White" Offset="0.526"/>
                                            <GradientStop Color="#005b7f" Offset="0.991"/>
                                            <GradientStop Color="#005b7f" Offset="1"/>
                                        </LinearGradientBrush>
                                    </Setter.Value>
                                </Setter>
                            </Trigger>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Background" TargetName="Border" Value="#5c99b1"/>
                                <Setter Property="Foreground" Value="White"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <!--#endregion-->
    </Application.Resources>
</Application>
 

约翰

C#论坛主持人
工作人员
加入
2011年4月23日
消息
1,114
地点
挪威
编程经验
10+
它归结为:
XML:
<Style TargetType="{x:Type TextBlock}">
    <Setter Property="Foreground" Value="Black"/>
</Style>

<Style TargetType="{x:Type Button}">
    <Setter Property="Foreground" Value="White" />
</Style>
福彩12选5走势图文本显示默认控制模板中的TextBlock。 为什么隐式教科块样式接管了一切
 
解决方案

Simsen.vejle.

成员
加入
2月14日,2021年
消息
21
编程经验
Beginner
它归结为:
XML:
<Style TargetType="{x:Type TextBlock}">
    <Setter Property="Foreground" Value="Black"/>
</Style>

<Style TargetType="{x:Type Button}">
    <Setter Property="Foreground" Value="White" />
</Style>
福彩12选5走势图文本显示默认控制模板中的TextBlock。 为什么隐式教科块样式接管了一切
太感谢了。我不知道。它的工作。

最好的祝福
Simsen.  :)
 
最佳 底部