Use VisualBrush to paint background

image_pdfimage_print


   
     

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
  x:Class="Microsoft.Samples.Graphics.UsingVisualBrush.PaintingWithVisuals">
    <StackPanel>
        <StackPanel.Background>
            <VisualBrush Opacity="0.1" Viewport="0,0,250,30" ViewportUnits="Absolute" TileMode="Tile" Stretch="None">
                <VisualBrush.Visual>
                    <Border Width="250" Background="Transparent">
                        <TextBlock Margin="5" FontSize="60px" >
              VisualBrush
              <TextBlock.Foreground>
                <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
                  <LinearGradientBrush.GradientStops>
                    <GradientStop Offset="0.0" Color="Black" />
                    <GradientStop Offset="1.0" Color="Red" />
                  </LinearGradientBrush.GradientStops>
                </LinearGradientBrush>
              </TextBlock.Foreground>
                        </TextBlock>
                    </Border>
                </VisualBrush.Visual>
                <VisualBrush.RelativeTransform>
                    <RotateTransform Angle="0" CenterX="0.5" CenterY="0.5" />
                </VisualBrush.RelativeTransform>
            </VisualBrush>
        </StackPanel.Background>
    </StackPanel>
</Page>