Reputation: 35
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..
<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>
Upvotes: 2
Views: 16054
Reputation: 4030
It's because the BorderBrush
is set to Transparent
. Assign a color to it.
<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 button
that even is visible on hover
, etc... than add a border element
around your 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>
Upvotes: 9