简体   繁体   English

window标题下的黑线

[英]Black line under the window title

How to get rid of the black color above the grid?如何摆脱网格上方的黑色?

登录视图,标题栏和窗口内容之间有一个黑条。

<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>

Your Border style is an implicit style that is defined in the Resources of your Window .您的Border样式是在WindowResources中定义的隐式样式。 If you remove your Grid and the other styles, you can see that the issue still persists and is perfectly reproducible, which means the Window is the cause.如果您删除您的Grid和其他 styles,您可以看到问题仍然存在并且完全可重现,这意味着Window是原因。 It seems that your implicit style affects the internal style of the Window in any way.看来您的隐式风格会以任何方式影响Window的内部风格。 This is the reason why the bar is black and setting a window background explicitly does not change this color.这就是为什么条形图为黑色并且明确设置 window 背景不会更改此颜色的原因。

If you still need to set the style of the Border implicitly, move it to a different inner scope, eg down to the next child control, eg the Grid or just give it an x:Key and reference it explicitly where needed.如果您仍然需要隐式设置Border的样式,请将其移动到不同的内部 scope,例如下一个子控件,例如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>

Otherwise remove the Margin setter completely and add it to the styles of other, specific controls.否则完全删除Margin setter 并将其添加到其他特定控件的 styles 中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM