There is a blue rectangle that is filled with a custom VisualBrush
(left image). A line is passing through the rectangle. How can I trim the brush to achieve the shape in right image.
Asked
Active
Viewed 546 times
0

Vahid
- 5,144
- 13
- 70
- 146
-
Post your custom visual brush code. – Rhyous Jun 04 '14 at 21:29
-
@Vahid is it always the same configuration where one rectangle is split into 2? – dkozl Jun 04 '14 at 21:31
1 Answers
0
Look at the LinearGradientBrush. You want to use do something like this to your custom VisualBrush.
<Rectangle Width="100" Height="200">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Blue" Offset="0"/>
<GradientStop Color="Blue" Offset="0.405"/>
<GradientStop Color="Black" Offset="0.405"/>
<GradientStop Color="Black" Offset="0.722"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
I don't know what your custom brush is, but if you allowed it to work similar to the gradient brush.
The other option is to actually have a two rectangles with a Separator in between and they each have a separate gradient brush. Then the red line would actually be the Separator background color.
<DockPanel Width="100" Height="200">
<Rectangle DockPanel.Dock="Top" Height="100" Margin="0">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="1"/>
<GradientStop Color="White"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Separator Height="2" DockPanel.Dock="Top" Background="Red" Margin="0"></Separator>
<Rectangle Margin="0" Fill="Black"/>
</DockPanel>

Rhyous
- 6,510
- 2
- 44
- 50