WPF 边框厚度仅底部..

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23266723/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 11:37:27  来源:igfitidea点击:

WPF Border thickness bottom only..

wpfxamlbutton

提问by eiv

I'm trying to create WPF button with only border on the bottom and the rest will hide. I try to use borderthickness = "0,0,0,1" but it doesn't work.. here is my codes..

我正在尝试创建底部只有边框的 WPF 按钮,其余的将隐藏。我尝试使用 borderthickness = "0,0,0,1" 但它不起作用.. 这是我的代码..

<Button Background="Transparent" BorderThickness="0,0,0,1" BorderBrush="Transparent"  Width="235" Padding="5" FlowDirection="LeftToRight">
<StackPanel Orientation="Horizontal" Width="260">
<Image Source="Images/room-32.png" Height="20" Margin="30,0,8,0"/>
<TextBlock Width="200">Station Maintenance</TextBlock>
</StackPanel>
</Button>

回答by Loetn

It's because the BorderBrushis set to Transparent. Assign a color to it.

这是因为BorderBrush设置为Transparent. 为其指定颜色。

<Button Background="Transparent" BorderThickness="0,0,0,1" BorderBrush="Black"  Width="235" Padding="5" FlowDirection="LeftToRight">
   <StackPanel Orientation="Horizontal" Width="260">
      <Image Source="Images/room-32.png" Height="20" Margin="30,0,8,0"/>
      <TextBlock Width="200">Station Maintenance</TextBlock>
   </StackPanel>
</Button>

So, instead of

所以,而不是

BorderBrush="Transparent"

use

BorderBrush="Black" // Any color you would like

EDIT

编辑

If you want a border around your buttonthat even is visible on hover, etc... than add a border elementaround your button.

如果你想在你的边界button,即使是可见的hover,等等...不是添加border element在你的button

  <Border BorderBrush="Black" BorderThickness="0,0,0,1">
      <Button Background="Transparent"
              Width="235"
              Padding="5"
              FlowDirection="LeftToRight">
          <StackPanel Orientation="Horizontal"
                      Width="260">
               <Image Source="Images/room-32.png"
                     Height="20"
                     Margin="30,0,8,0" />
               <TextBlock Width="200">Station Maintenance</TextBlock>
          </StackPanel>
      </Button>
  </Border>