2012-08-03 13 views

Odpowiedz

12

Tworzy wzór pasków pod kątem 45 stopni w dół. Alter rzutnia do zmiany rozmiaru pasków

<DrawingBrush Stretch="UniformToFill" ViewportUnits="Absolute" Viewport="0,0,10,10" TileMode="Tile"> 
    <DrawingBrush.Drawing> 
     <DrawingGroup> 
      <DrawingGroup.Children> 
       <GeometryDrawing Brush="Black"> 
        <GeometryDrawing.Geometry> 
         <GeometryGroup FillRule="Nonzero"> 
          <PathGeometry> 
           <PathFigure StartPoint="0,0"> 
            <LineSegment Point="100,0"/> 
            <LineSegment Point="100,100"/> 
            <LineSegment Point="0,100"/> 
           </PathFigure> 
          </PathGeometry> 
         </GeometryGroup> 
        </GeometryDrawing.Geometry> 
       </GeometryDrawing> 
       <GeometryDrawing Brush="#FF404040"> 
        <GeometryDrawing.Geometry> 
         <GeometryGroup FillRule="Nonzero"> 
          <PathGeometry> 
           <PathFigure StartPoint="0,0"> 
            <LineSegment Point="25,0"/> 
            <LineSegment Point="100,75"/> 
            <LineSegment Point="100,100"/> 
            <LineSegment Point="75,100"/> 
            <LineSegment Point="0,25"/> 
            <LineSegment Point="0,0"/> 
           </PathFigure> 
           <PathFigure StartPoint="75,0"> 
            <LineSegment Point="100,25"/> 
            <LineSegment Point="100,0"/> 
           </PathFigure> 
           <PathFigure StartPoint="0,75"> 
            <LineSegment Point="25,100"/> 
            <LineSegment Point="0,100"/> 
           </PathFigure> 
          </PathGeometry> 
         </GeometryGroup> 
        </GeometryDrawing.Geometry> 
       </GeometryDrawing> 
      </DrawingGroup.Children> 
     </DrawingGroup> 
    </DrawingBrush.Drawing> 
</DrawingBrush> 

Ewentualnie można wiązać skala przekształcić do wysokości i szerokości kontroli przy użyciu MultiBinding. Następnie za pomocą konwertera zmieniasz skalę na maksymalną wysokość lub szerokość, a paski pozostaną niezmienione.

11

Wystarczy użyć 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> 
Powiązane problemy