点击或悬停时会出现这些边框,直到焦点丢失才会出现这些边框。 四边都有边框,但由于它嵌入较短的网格中,因此顶部和底部都不可见。 如何删除这些边框? 如果可能,请提供一个例子。
XAML:
<Border x:Name="SearchBorder" BorderThickness="1" HorizontalAlignment="Left" Height="40" Margin="672,34,0,0" VerticalAlignment="Top" Width="355" Background="#3F000000">
<Border.BorderBrush>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#4C000000" Offset="0"/>
<GradientStop Color="#3FFFFFFF" Offset="1"/>
</LinearGradientBrush>
</Border.BorderBrush>
<Grid>
<TextBox x:Name="SearchBox" HorizontalAlignment="Left" Height="40" Width="296" Margin="10,0,0,0" TextWrapping="Wrap" VerticalAlignment="Center" SelectionBrush="Black" Background="#00000000" Foreground="#FF5B5B5B" FontSize="25" FontFamily="Segoe UI Light" BorderBrush="#00000000" CaretBrush="#FF6C6C6C"/>
<TextBlock HorizontalAlignment="Left" Height="23" Margin="320,0,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Center" Width="21" FontFamily="FontAwesome" FontSize="25" Foreground="#FF919191"/>
<Rectangle HorizontalAlignment="Left" Margin="311,-2,0,0" Width="1">
<Rectangle.Stroke>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#3F404040" Offset="0"/>
<GradientStop Color="#3F686868" Offset="1"/>
<GradientStop Color="#59DADADA" Offset="0.502"/>
</LinearGradientBrush>
</Rectangle.Stroke>
</Rectangle>
</Grid>
</Border>
答案 0 :(得分:38)
尝试BorderThickness="0"
<TextBox x:Name="SearchBox" BorderThickness="0" HorizontalAlignment="Left" Height="40" Width="296" Margin="10,0,0,0" TextWrapping="Wrap" VerticalAlignment="Center" SelectionBrush="Black" Background="#00000000" Foreground="#FF5B5B5B" FontSize="25" FontFamily="Segoe UI Light" BorderBrush="#00000000" CaretBrush="#FF6C6C6C"/>
答案 1 :(得分:2)
您可以通过仅将BorderBrush属性设置为Transparent来删除边框。
答案 2 :(得分:0)
普通视图:将BorderBrush属性设置为“透明”
<Button Name="BtnTest"
Content="Test"
BorderBrush="Transparent"
Height="20"
Width="75"/>
悬停视图:在用鼠标悬停控件时,在Window.Resources标记下包括这些按钮控件模板或诸如Textbox或Textblock等任何控件。
<Window.Resources>
<Style TargetType="Button">
<!--Default Values-->
<Setter Property="BorderBrush"
Value="Transparent"/>
<!--Transparent Highlight-->
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>