Mikolaj Palkiewicz
Mikolaj Palkiewicz

Reputation: 15

Hide half of border with grid

How hide half of brush with opacity mask with no path element? I want to make site "transparent".

    <Border Height="32" Width="32" x:Name="b1" CornerRadius="50" BorderThickness="3" BorderBrush="Red">

    </Border>
    <Grid Height="32" Width="16" HorizontalAlignment="Right" x:Name="hideHaf" Background="Blue" >

    </Grid>

Default:

enter image description here

I want:

enter image description here

Upvotes: 1

Views: 172

Answers (2)

gomi42
gomi42

Reputation: 2519

Just in case your primary goal is to draw a vertical half transparent circle. You could do it this way instead of using the Border:

    <Path Width="16" Height="32" Stretch="Fill" Data="M5,0 A5,5,0,0,0,5,10" Stroke="Red" StrokeThickness="3" HorizontalAlignment="Left" VerticalAlignment="Top"/>

Upvotes: 0

Joe
Joe

Reputation: 7004

You could simply put your border insize the grid, and use the default ClipToBounds="True" property of the grid to clip the border like this:

    <Grid Height="32" Width="16" HorizontalAlignment="Right" x:Name="hideHaf">
        <Border Height="32" Width="32" x:Name="b1" CornerRadius="50" BorderThickness="3" BorderBrush="Red"/>
    </Grid>

Which produces:

enter image description here

Upvotes: 2

Related Questions