Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shape with slanted lines as background

Is possible to draw a Shape that has a background made by slanted lines?

An example with Rectangle (sorry for the image quality):

enter image description here

And if i want dashed lines or change the line properties (stroke, thickness..)?

like image 421
Nick Avatar asked Dec 30 '25 00:12

Nick


1 Answers

You can use solution from this article http://mark-dot-net.blogspot.com/2007/06/creating-hatched-patterned-brush-in-wpf.html

<VisualBrush
  x:Key="HatchBrush"
  TileMode="Tile" Viewport="0,0,10,10"
  ViewportUnits="Absolute" Viewbox="0,0,10,10"   
  ViewboxUnits="Absolute">
  <VisualBrush.Visual>
    <Canvas>
       <Rectangle Fill="Azure" Width="10" Height="10" />
       <Path Stroke="Purple" Data="M 0 0 l 10 10" />
    </Canvas>
  </VisualBrush.Visual>
</VisualBrush>

Just change the parameters etc. to fit your application

Usage:

<Rectangle Width="80" Height="40"
    Fill="{StaticResource HatchBrush}"/>
like image 68
Ribtoks Avatar answered Dec 31 '25 13:12

Ribtoks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!