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.

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.

Copyright © 2021 Jogjafile Inc.
Look at the LinearGradientBrush. You want to use do something like this to your custom VisualBrush.
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.