adjust border on one specific side

2019-04-17 22:31发布

问题:

I'm using a controlTemplate of the ListBox to show a collection. I want to display all the items with a border like in a grid (all lines same size). When I give every listBoxItem a border, the line between 2 items has a double size. (made from the bottom border of the first item, and the top border of the second item)

So the question is: Can I set/hide the border on a single side of an item? (like 'border-top' in css)

回答1:

The border property is a thickness, just like margin and padding, so you can do Border="2,0,2,2" to get a border of 2 everywhere except the top.