WPF 边框厚度仅底部..

标签 wpf xaml button

我正在尝试创建底部只有边框的 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>

最佳答案

这是因为 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>

所以,而不是

BorderBrush="Transparent"

使用

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

编辑

如果你想在你的 button 周围添加一个边框,甚至在 hover 等时都可见...那么在你的周围添加一个 border 元素 按钮

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

关于WPF 边框厚度仅底部..,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23266723/

相关文章:

c# - 线程保留内存

c# - 使用带有 C# 的 XAML 为 Windows Phone 8 应用程序设置计时器

wpf - 无法识别目标名称

html - 为什么 flexbox justify-content 使我的 'block' 按钮内联?

jquery - 禁用表单提交,直到选中(两个)复选框

c# - 设置 Stroke on Line 导致 Anti-Virus 停止编译

c# - 如何使用 CollectionViewSource 正确绑定(bind)(更新)DataGrid

arrays - 数组序列(字符串)返回下一个可见按钮 - React

wpf - 当 Aero 被禁用时,WPF 应用程序的性能更差?

TreeViewItem 元素中的 C# 选项卡索引