我有这个例子作为 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>
我需要在后面的代码中编写相同的代码,但我只能这样做:
VisualBrush vb = new VisualBrush();
vb.Viewport = new Rect(0, 0, 5, 5);
vb.TileMode = TileMode.Tile;
老实说,我不知道如何编写路径数据。我怎样才能做到这一点?