<Style x:Key="WindowBackground" TargetType="Grid">
<Setter Property="Background">
<Setter.Value>
<DrawingBrush>
<DrawingBrush.Drawing>
<DrawingGroup>
<GeometryDrawing>
<GeometryDrawing.Brush>
<RadialGradientBrush GradientOrigin="0.5,0.5" RadiusX="0.5" RadiusY="0.5">
<GradientStop Color="#EE9D40" Offset="0"/>
<GradientStop Color="#BF8230" Offset="1"/>
</RadialGradientBrush>
</GeometryDrawing.Brush>
<GeometryDrawing.Geometry>
<RectangleGeometry Rect="0,0,1,1"/>
</GeometryDrawing.Geometry>
</GeometryDrawing>
<GeometryDrawing>
<GeometryDrawing.Brush>
<DrawingBrush TileMode="Tile" Stretch="None" Viewbox="0,0,1,1" Viewport="0,0,25,25" ViewportUnits="Absolute">
<DrawingBrush.RelativeTransform>
<TranslateTransform X="0" Y="0" />
</DrawingBrush.RelativeTransform>
<DrawingBrush.Drawing>
<GeometryDrawing Brush="#20FFFFFF" Geometry="M10,0 22,0 12,25 0,22 Z" />
</DrawingBrush.Drawing>
</DrawingBrush>
</GeometryDrawing.Brush>
<GeometryDrawing.Geometry>
<RectangleGeometry Rect="0,0,1,1"/>
</GeometryDrawing.Geometry>
</GeometryDrawing>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
</Setter.Value>
</Setter>
</Style>
答案 0 :(得分:19)
这个技巧应该有用。
<LinearGradientBrush EndPoint="0,0" StartPoint="8,8"
MappingMode="Absolute" SpreadMethod="Repeat">
<GradientStop Color="Black" Offset="0" />
<GradientStop Color="Black" Offset="0.1" />
<GradientStop Color="White" Offset="0.1" />
<GradientStop Color="White" Offset="1" />
</LinearGradientBrush>
答案 1 :(得分:1)
我终于让它工作了,但不是像我想要的那样只用一个复合刷。我使用了以下样式:
<Style x:Key="WindowBackground" TargetType="Grid">
<Setter Property="Background">
<Setter.Value>
<RadialGradientBrush GradientOrigin="0.5,0.5" RadiusX="0.5" RadiusY="0.5">
<GradientStop Color="#EAA659" Offset="0"/>
<GradientStop Color="#BF8230" Offset="1"/>
</RadialGradientBrush>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="HatchOverlay" TargetType="Rectangle">
<Setter Property="Fill">
<Setter.Value>
<VisualBrush Opacity=".1" TileMode="Tile" Viewport="0,0,10,20" ViewportUnits="Absolute">
<VisualBrush.Visual>
<Canvas>
<Path Stroke="#825821" Data="M 0 0 l 10 20" />
</Canvas>
</VisualBrush.Visual>
</VisualBrush>
</Setter.Value>
</Setter>
</Style>
然后,为了在运行时启用它,我添加了一个矩形作为我的网格的第一个子节点,如下所示:
<Grid Style="{StaticResource WindowBackground}">
<Rectangle Style="{StaticResource HatchOverlay}"/>...
这让我觉得我追求的效果。谢谢你的帮助;我会向你们每个人投票。
答案 2 :(得分:1)
尝试旋转水平线刷以避免角落间隙:
<VisualBrush TileMode="Tile"
Viewport="0,0,5,5" ViewportUnits="Absolute"
Viewbox="0,0,5,5" ViewboxUnits="Absolute">
<VisualBrush.Visual>
<Grid Background="White" Height="5">
<Path Stroke="Black" Data="M 0 3 l 8 0" />
</Grid>
</VisualBrush.Visual>
<VisualBrush.RelativeTransform>
<RotateTransform CenterX="0.5" CenterY="0.5" Angle="45" />
</VisualBrush.RelativeTransform>
</VisualBrush>