I have this example as XAML:
<VisualBrush x:Key="HatchBrush" TileMode="Tile" Viewport="0,0,5,5" ViewportUnits="Absolute" Viewbox="0,0,5,5" ViewboxUnits="Absolute" po:Freeze="True">
<VisualBrush.Visual>
<Path Data="M 0 5 L 5 0 M -2 2 L 2 -2 M 3 7 L 7 3"
Stroke="#80ffffff" StrokeEndLineCap="Square"
RenderOptions.EdgeMode="Aliased" />
</VisualBrush.Visual>
I need to write the same in code behind but I've been able to do only this:
VisualBrush vb = new VisualBrush();
vb.Viewport = new Rect(0, 0, 5, 5);
vb.TileMode = TileMode.Tile;
Honestly I dunno how to write the Path Data. How can I do this?
You could write
However, you don't need to use a VisualBrush at all.
The XAML below shows how to use a DrawingBrush with two drawings to get the hatch pattern on top of a solid color background.