1. Image brushes
Imagebrush: Specify the imagesource. If you consider the effect, you can use it together with the viewport and tilemode attributes to improve the effect.
<Textbox width = "200" Height = "20" text = "WPF learning summary"> <textbox. foreground> <imagebrush imagesource = "ticket.png" viewport = "0.3, 0.3," tilemode = "tile"> </imagebrush> </textbox. foreground> </textbox>
2. Linear Gradient painting brush
Lineargradientbrush: Specifies the startpoint and Endpoint attributes, and uses the color and offset attributes of gradientstop to specify different colors and the starting offset respectively.
<Rectangle Width="100" Height="100"> <Rectangle.Fill> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> <GradientStop Color="Black" Offset="0"></GradientStop> <GradientStop Color="White" Offset="1"></GradientStop> </LinearGradientBrush> </Rectangle.Fill> </Rectangle>
3. Radiation gradient Paint Brush
Radialgradientbrush uses the gradientorigin attribute to specify the position of the Radiation Center, and uses the color and offset attributes of gradientstop to specify different colors and start offsets respectively.
<Ellipse Width="100" Height="100"> <Ellipse.Fill> <RadialGradientBrush GradientOrigin="0.8,0.9"> <GradientStop Color="Black" Offset="0"></GradientStop> <GradientStop Color="White" Offset="1"></GradientStop> </RadialGradientBrush> </Ellipse.Fill> </Ellipse>
4. Visual painter
Visualbrush, which specifies the visual attributes and can be used with transform to produce the reflection effect.
<TextBox Width="100" Height="50" x:Name="textBox1" Margin="12,12,391,249"></TextBox><Rectangle Height="50" HorizontalAlignment="Left" Margin="9,73,0,0" StrokeThickness="0" Name="rectangle1" Stroke="Black" VerticalAlignment="Top" Width="105"> <Rectangle.Fill> <VisualBrush Visual="{Binding ElementName=textBox1}"> <VisualBrush.RelativeTransform> <TransformGroup> <ScaleTransform ScaleX="1" ScaleY="-1"></ScaleTransform> <TranslateTransform Y="1"></TranslateTransform> </TransformGroup> </VisualBrush.RelativeTransform> </VisualBrush> </Rectangle.Fill></Rectangle>