Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Different Color to each side in Border in WPF XAML?

Tags:

wpf

xaml

I want to have different color to each side of a border in WPF XAML. How can i do this.

<Border BorderThickness="1,2,3,4" BorderBrush="Blue"></Border>
like image 605
Kishore Kumar Avatar asked Mar 28 '12 17:03

Kishore Kumar


3 Answers

A bit hacky, 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>

Probably better to create your own Decorator.

like image 113
GazTheDestroyer Avatar answered Nov 03 '22 02:11

GazTheDestroyer


Maybe?

    <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>
like image 21
Phil Avatar answered Nov 03 '22 01:11

Phil


There is a hacky way that using four Border 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>
like image 32
J.B.D Avatar answered Nov 03 '22 00:11

J.B.D