Different color on each side in Border in WPF XAML?

I want to have different colors for each side of the border in WPF XAML. How can i do this.

<Border BorderThickness="1,2,3,4" BorderBrush="Blue"></Border>
+5
source share
3 answers

May be,?

    <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>
+4
source

A bit hacked, but it works.

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

It might be better to create your own Decorator.

+4
source

There is a hacker way to use the four border fooobar.com/questions/172455 / ...

<Border BorderThickness="0,0,0,10" BorderBrush="Green">
    <Border BorderThickness="0,0,10,0" BorderBrush="Blue">
        <Grid>
            <Button>Hello</Button>
        </Grid>
    </Border>
</Border>
0
source

All Articles