Pregunta

I want to have a Rectangle filled with a checkerboard, which is overlayed by a LinearGradientBrush. Only the GradientBrush or only the Checkerboard-DrawingBrush is no Problem. But how to overlay both in the Fill-Property? I can not put the Gradient in the DrawingGroup , because the Gradient would be tiled too.

This is the Checkerboard-DrawingBrush:

<Rectangle.Fill>
    <DrawingBrush Viewport="0,0,0.5,0.05" TileMode="Tile">
        <DrawingBrush.Drawing>
            <DrawingGroup>
                <GeometryDrawing Brush="White">
                    <GeometryDrawing.Geometry>
                        <RectangleGeometry Rect="0,0,100,100"  />
                    </GeometryDrawing.Geometry>
                </GeometryDrawing>
                <GeometryDrawing >
                    <GeometryDrawing.Geometry>
                        <GeometryGroup>
                            <RectangleGeometry Rect="0,0,50,50" />
                            <RectangleGeometry Rect="50,50,50,50" />
                        </GeometryGroup>
                    </GeometryDrawing.Geometry>
                    <GeometryDrawing.Brush >
                        <LinearGradientBrush>
                            <GradientStop Offset="0.0" Color="Black" />
                            <GradientStop Offset="1.0" Color="Gray" />
                        </LinearGradientBrush>
                    </GeometryDrawing.Brush>
                </GeometryDrawing>
            </DrawingGroup>
        </DrawingBrush.Drawing>
    </DrawingBrush>
</Rectangle.Fill>

So how to apply my Gradient over the whole Rectangle?

<LinearGradientBrush>
     <GradientStop Color="White" Offset="0" />
     <GradientStop Color="Transparent" Offset="1" />
</LinearGradientBrush>
¿Fue útil?

Solución

I would do this:

<Grid>
    <Rectangle … checkerboard
    <Rectangle … gradient
</Grid>
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top