Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create stripe brush in WPF

Tags:

wpf

brush

How can I create a brush (DrawingBrush) for stripes as shown in the blog:

http://blog.pixelingene.com/2008/09/quick-tip-to-get-a-striped-background/

I can't use it because it uses scale transform, which means if the UI element is small, the stripes are pretty much not visible or too close together.

I can't use image brush because I need to bind the colors.

like image 999
Metro Avatar asked Aug 03 '12 17:08

Metro


1 Answers

Just use MappingMode="Absolute":

<LinearGradientBrush MappingMode="Absolute" x:Key="HatchBrush"  StartPoint="0,0" EndPoint="4,4" SpreadMethod="Repeat">
  <GradientStop Offset="0" Color="LightCoral"/>
  <GradientStop Offset="0.75" Color="LightCoral"/>
  <GradientStop Offset="0.75" Color="Gray"/>
  <GradientStop Offset="1" Color="Gray"/>
</LinearGradientBrush>
like image 131
tom-englert Avatar answered Sep 25 '22 14:09

tom-englert