我想在WPF XAML的邊框的每一邊都有不同的顏色。我怎樣才能做到這一點。WPF XAML中邊框各邊的顏色不同?
<Border BorderThickness="1,2,3,4" BorderBrush="Blue"></Border>
我想在WPF XAML的邊框的每一邊都有不同的顏色。我怎樣才能做到這一點。WPF XAML中邊框各邊的顏色不同?
<Border BorderThickness="1,2,3,4" BorderBrush="Blue"></Border>
也許?
<DockPanel LastChildFill="True">
<Rectangle Fill="Red" DockPanel.Dock="Top" Height="2"/>
<Rectangle Fill="Yellow" DockPanel.Dock="Left" Width="2"/>
<Rectangle Fill="Green" DockPanel.Dock="Right" Width="2"/>
<Rectangle Fill="Blue" DockPanel.Dock="Bottom" Height="2"/>
<Rectangle Fill="Wheat"/>
</DockPanel>
有點哈克,但它的工作原理。
<Grid>
<Border BorderThickness="1,0,0,0" BorderBrush="Blue"/>
<Border BorderThickness="0,2,0,0" BorderBrush="Red"/>
<Border BorderThickness="0,0,3,0" BorderBrush="Green"/>
<Border BorderThickness="0,0,0,4" BorderBrush="Orange"/>
</Grid>
可能更好地創建自己的Decorator
。
有采用四個邊境哈克的方式https://stackoverflow.com/a/1797045/5229294
<Border BorderThickness="0,0,0,10" BorderBrush="Green">
<Border BorderThickness="0,0,10,0" BorderBrush="Blue">
<Grid>
<Button>Hello</Button>
</Grid>
</Border>
</Border>