window标题下的黑线

Black line under the window title

如何去除网格上方的黑色?

<Window x:Class="Nipendo.Desktop.Biur.Login.LoginWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:adorners="http://gu.se/Adorners"
    mc:Ignorable="d"
    Title="Nipendo Sign Tool" Height="600" Width="600"
    Background="White"
    FlowDirection="{Binding FlowDirection}">
<Window.Resources>
    <Style TargetType="ComboBox">
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="Height" Value="20"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Setter Property="FontSize" Value="12"/>
        <Setter Property="Width" Value="90"/>
    </Style>
    <Style TargetType="Border">
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="BorderBrush" Value="Gray"/>
        <Setter Property="CornerRadius" Value="2"/>
        <Setter Property="Margin" Value="0,15,0,0"/>
    </Style>
    <Style TargetType="TextBox">
        <Setter Property="HorizontalAlignment" Value="Stretch"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="Height" Value="30"/>
        <Setter Property="FontSize" Value="15"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
    </Style>
    <Style TargetType="PasswordBox">
        <Setter Property="HorizontalAlignment" Value="Stretch"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="Height" Value="30"/>
        <Setter Property="FontSize" Value="15"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
    </Style>
    <Style TargetType="Button">
        <Setter Property="Background" Value="#37b0eb"/>
        <Setter Property="FontSize" Value="16"/>
        <Setter Property="Foreground" Value="White"/>
        <Setter Property="Height" Value="30"/>
        <Setter Property="Margin" Value="0,15,0,0"/>
    </Style>
    <Style TargetType="{x:Type adorners:WatermarkAdorner}">
        <Setter Property="TextStyle">
            <Setter.Value>
                <Style TargetType="{x:Type TextBlock}">
                    <Setter Property="Opacity" Value="0.5" />
                    <Setter Property="VerticalAlignment" Value="Center"/>
                </Style>
            </Setter.Value>
        </Setter>
    </Style>
</Window.Resources>
<Grid Margin="15">
    <Image Grid.Row="1" Grid.Column="1" Source="/Resources/Icons/login_nipendo-logo.png" Height="70" Width="130" VerticalAlignment="Top" HorizontalAlignment="Left"/>
    <ComboBox Grid.Row="1" 
              Grid.Column="1"  
              HorizontalAlignment="Right" 
              Name="comboLanguage" 
              VerticalAlignment="Top" 
              ItemsSource="{Binding Languages}"
              SelectedItem="{Binding SelectedLanguage}"
              DisplayMemberPath="Name">
    </ComboBox>
    <StackPanel Grid.Row="2" VerticalAlignment="center" HorizontalAlignment="Center" MinWidth="350" MaxWidth="450">
        <TextBlock Text="{Binding SignInTitleText}" 
               FontWeight="Bold" 
               FontSize="25" 
               Margin="0,0,0,15"/>
        <Border>
            <DockPanel>
                <Image DockPanel.Dock="Left" Source="/Resources/Icons/login_site.png" Width="20" Height="20"></Image>
                <TextBox Name="txtSiteName" Text="{Binding SiteName}" adorners:Watermark.Text="{Binding SiteNameText}">
                </TextBox>
            </DockPanel>
        </Border>
        <Border >
            <DockPanel>
                <Image DockPanel.Dock="Left" Source="/Resources/Icons/login_user.png" Width="20" Height="20"/>
                <TextBox Name="txtUserName" Text="{Binding UserName}" adorners:Watermark.Text="{Binding UserNameText}"></TextBox>
            </DockPanel>
        </Border>
        <Border >
            <DockPanel>
                <Image DockPanel.Dock="Left" Source="/Resources/Icons/login_password.png" Width="20" Height="20"/>
                <PasswordBox Name="txtPassword" PasswordChanged="txtPassword_PasswordChanged" adorners:Watermark.Text="{Binding PasswordText}"></PasswordBox>
            </DockPanel>
        </Border>
        <Button Name="btnSubmit" Content="{Binding SignInButtonText}" IsEnabled="{Binding CanSubmit}" Command="{Binding SubmitCommand}"/>
    </StackPanel>

    <StackPanel Grid.Row="3" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Bottom" Height="35">
        <TextBlock FontSize="12" Text="{Binding NeedHelpText}" Foreground="#bcc3c7"/>
    </StackPanel>
    
    <StackPanel Grid.Row="4" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Bottom">
        <TextBlock FontSize="12">
            <Hyperlink NavigateUri="{Binding HelpUrl}"  RequestNavigate="Hyperlink_RequestNavigate" >
                <TextBlock Text="{Binding HelpText}"></TextBlock>
            </Hyperlink>
        </TextBlock>
        <TextBlock FontSize="12" Margin="10,0,10,0">|</TextBlock>
        <TextBlock FontSize="12">
            <Hyperlink NavigateUri="{Binding SupportEmail}" RequestNavigate="Hyperlink_RequestNavigate">
                <TextBlock Text="{Binding SupportEmailText}"></TextBlock>
            </Hyperlink>
        </TextBlock>
        <TextBlock FontSize="12" Margin="10,0,10,0">|</TextBlock>
        <TextBlock FontSize="12">
            <Hyperlink NavigateUri="{Binding NipendoUrl}" RequestNavigate="Hyperlink_RequestNavigate">
                <TextBlock Text="{Binding NipendoUrlText}"></TextBlock>
            </Hyperlink>
        </TextBlock>
    </StackPanel>
</Grid>

您的 Border 样式是在 WindowResources 中定义的 隐式 样式。如果删除 Grid 和其他样式,您会发现问题仍然存在并且可以完美重现,这意味着 Window 是原因。似乎您的隐式样式以任何方式影响 Window 的内部样式。这就是为什么条形图是黑色的并且明确设置 window 背景不会更改此颜色的原因。

如果您仍然需要隐式设置 Border 的样式,请将其移动到不同的内部范围,例如向下到下一个子控件,例如Grid 或者只是给它一个 x:Key 并在需要的地方明确引用它。

<Grid Margin="15">
   <Grid.Resources>
      <Style TargetType="Border">
         <Setter Property="BorderThickness" Value="1"/>
         <Setter Property="BorderBrush" Value="Gray"/>
         <Setter Property="CornerRadius" Value="2"/>
         <Setter Property="Margin" Value="0,15,0,0"/>
      </Style>
   </Grid.Resources>
   <!-- ...your grid markup. -->
</Grid>

否则完全删除 Margin setter 并将其添加到其他特定控件的样式中。