Cenni preliminari sui pennelli di WPFWPF Brushes Overview

Qualsiasi elemento visibile sullo schermo è visibile, perché sono stati disegnati con un pennello.Everything visible on your screen is visible because it was painted by a brush. Ad esempio, un pennello viene utilizzato per descrivere lo sfondo di un pulsante, il primo piano del testo e il riempimento di una forma.For example, a brush is used to describe the background of a button, the foreground of text, and the fill of a shape. In questo argomento vengono illustrati i concetti di disegno con Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) pennelli e vengono forniti esempi.This topic introduces the concepts of painting with Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) brushes and provides examples. I pennelli consentono di disegnare oggetti interfaccia utenteuser interface (UI) con colori semplici a tinta unita, fino a set complessi di motivi e immagini.Brushes enable you to paint interfaccia utenteuser interface (UI) objects with anything from simple, solid colors to complex sets of patterns and images.

Disegno con pennelloPainting with a Brush

Oggetto Brush "disegna" un'area con il proprio output.A Brush "paints" an area with its output. Pennelli diversi hanno tipi diversi di output.Different brushes have different types of output. Alcuni pennelli disegnano un'area con un colore a tinta unita, altri utenti con una sfumatura, motivo, immagine o disegno.Some brushes paint an area with a solid color, others with a gradient, pattern, image, or drawing. Nella figura seguente vengono illustrati esempi di tutti i diversi Brush tipi.The following illustration shows examples of each of the different Brush types.

Tipi di pennelloBrush types
Esempi di pennelloBrush examples

La maggior parte degli oggetti visivi consentono di specificare la modalità di disegno.Most visual objects enable you to specify how they are painted. Nella tabella seguente sono elencati alcuni oggetti e proprietà a cui è possibile utilizzare comuni un Brush.The following table lists some common objects and properties with which you can use a Brush.

ClasseClass Proprietà BrushBrush properties
Border BorderBrush, BackgroundBorderBrush, Background
Control Background, ForegroundBackground, Foreground
Panel Background
Pen Brush
Shape Fill, StrokeFill, Stroke
TextBlock Background

Nelle sezioni seguenti vengono descritti i diversi Brush tipi e viene fornito un esempio di ognuno.The following sections describe the different Brush types and provide an example of each.

Disegno con un colore a tinta unitaPaint with a Solid Color

Oggetto SolidColorBrush disegna un'area con un solido Color.A SolidColorBrush paints an area with a solid Color. Esistono diversi modi per specificare il Color di un SolidColorBrush: ad esempio, è possibile specificare i canali alfa, rossi, blu e verde o utilizzare uno dei colori predefiniti forniti dalla Colors classe.There are a variety of ways to specify the Color of a SolidColorBrush: for example, you can specify its alpha, red, blue, and green channels or use one of the predefined color provided by the Colors class.

Nell'esempio seguente viene utilizzato un SolidColorBrush per disegnare il Fill di un Rectangle.The following example uses a SolidColorBrush to paint the Fill of a Rectangle. Nella figura seguente viene illustrato il rettangolo disegnato.The following illustration shows the painted rectangle.

Rettangolo disegnato usando SolidColorBrushA rectangle painted using a SolidColorBrush
Rettangolo disegnato usando SolidColorBrushA Rectangle painted using a SolidColorBrush

Rectangle exampleRectangle = new Rectangle();
exampleRectangle.Width = 75;
exampleRectangle.Height = 75;

// Create a SolidColorBrush and use it to
// paint the rectangle.
SolidColorBrush myBrush = new SolidColorBrush(Colors.Red);
exampleRectangle.Fill = myBrush;
Dim exampleRectangle As New Rectangle()
exampleRectangle.Width = 75
exampleRectangle.Height = 75

' Create a SolidColorBrush and use it to
' paint the rectangle.
Dim myBrush As New SolidColorBrush(Colors.Red)
exampleRectangle.Fill = myBrush
<Rectangle Width="75" Height="75">
  <Rectangle.Fill>
    <SolidColorBrush Color="Red" />
  </Rectangle.Fill>
</Rectangle>

Per ulteriori informazioni sul SolidColorBrush classe, vedere disegni con colori a tinta unita e sfumature Panoramica.For more information about the SolidColorBrush class, see Painting with Solid Colors and Gradients Overview.

Disegno con sfumatura linearePaint with a Linear Gradient

Oggetto LinearGradientBrush disegna un'area con una sfumatura lineare.A LinearGradientBrush paints an area with a linear gradient. Sfumatura lineare unisce due o più colori in una riga, l'asse delle sfumature.A linear gradient blends two or more colors across a line, the gradient axis. Utilizzare GradientStop oggetti per specificare i colori della sfumatura e le relative posizioni.You use GradientStop objects to specify the colors in the gradient and their positions.

Nell'esempio seguente viene utilizzato un LinearGradientBrush per disegnare il Fill di un Rectangle.The following example uses a LinearGradientBrush to paint the Fill of a Rectangle. Nella figura seguente viene illustrato il rettangolo disegnato.The following illustration shows the painted rectangle.

Rettangolo disegnato usando LinearGradientBrushA rectangle painted using a LinearGradientBrush
Rettangolo disegnato usando LinearGradientBrushA Rectangle painted using a LinearGradientBrush

Rectangle exampleRectangle = new Rectangle();
exampleRectangle.Width = 75;
exampleRectangle.Height = 75;

// Create a LinearGradientBrush and use it to
// paint the rectangle.
LinearGradientBrush myBrush = new LinearGradientBrush();
myBrush.GradientStops.Add(new GradientStop(Colors.Yellow, 0.0));
myBrush.GradientStops.Add(new GradientStop(Colors.Orange, 0.5));
myBrush.GradientStops.Add(new GradientStop(Colors.Red, 1.0));

exampleRectangle.Fill = myBrush;
Dim exampleRectangle As New Rectangle()
exampleRectangle.Width = 75
exampleRectangle.Height = 75

' Create a LinearGradientBrush and use it to
' paint the rectangle.
Dim myBrush As New LinearGradientBrush()
myBrush.GradientStops.Add(New GradientStop(Colors.Yellow, 0.0))
myBrush.GradientStops.Add(New GradientStop(Colors.Orange, 0.5))
myBrush.GradientStops.Add(New GradientStop(Colors.Red, 1.0))

exampleRectangle.Fill = myBrush
<Rectangle Width="75" Height="75">
  <Rectangle.Fill>
    <LinearGradientBrush>
      <GradientStop Color="Yellow" Offset="0.0" />
      <GradientStop Color="Orange" Offset="0.5" />
      <GradientStop Color="Red" Offset="1.0" />
    </LinearGradientBrush>
  </Rectangle.Fill>
</Rectangle>

Per ulteriori informazioni sul LinearGradientBrush classe, vedere disegni con colori a tinta unita e sfumature Panoramica.For more information about the LinearGradientBrush class, see Painting with Solid Colors and Gradients Overview.

Disegno con sfumatura radialePaint with a Radial Gradient

Oggetto RadialGradientBrush disegna un'area con una sfumatura radiale.A RadialGradientBrush paints an area with a radial gradient. Una sfumatura radiale unisce due o più colori in un cerchio.A radial gradient blends two or more colors across a circle. Come con la LinearGradientBrush (classe), utilizzare GradientStop oggetti per specificare i colori della sfumatura e le relative posizioni.As with the LinearGradientBrush class, you use GradientStop objects to specify the colors in the gradient and their positions.

Nell'esempio seguente viene utilizzato un RadialGradientBrush per disegnare il Fill di un Rectangle.The following example uses a RadialGradientBrush to paint the Fill of a Rectangle. Nella figura seguente viene illustrato il rettangolo disegnato.The following illustration shows the painted rectangle.

Rettangolo disegnato usando RadialGradientBrushA rectangle painted using a RadialGradientBrush
Rettangolo disegnato usando RadialGradientBrushA Rectangle painted using a RadialGradientBrush

Rectangle exampleRectangle = new Rectangle();
exampleRectangle.Width = 75;
exampleRectangle.Height = 75;

// Create a RadialGradientBrush and use it to
// paint the rectangle.
RadialGradientBrush myBrush = new RadialGradientBrush();
myBrush.GradientOrigin = new Point(0.75, 0.25);
myBrush.GradientStops.Add(new GradientStop(Colors.Yellow, 0.0));
myBrush.GradientStops.Add(new GradientStop(Colors.Orange, 0.5));
myBrush.GradientStops.Add(new GradientStop(Colors.Red, 1.0));

exampleRectangle.Fill = myBrush;
Dim exampleRectangle As New Rectangle()
exampleRectangle.Width = 75
exampleRectangle.Height = 75

' Create a RadialGradientBrush and use it to
' paint the rectangle.
Dim myBrush As New RadialGradientBrush()
myBrush.GradientOrigin = New Point(0.75, 0.25)
myBrush.GradientStops.Add(New GradientStop(Colors.Yellow, 0.0))
myBrush.GradientStops.Add(New GradientStop(Colors.Orange, 0.5))
myBrush.GradientStops.Add(New GradientStop(Colors.Red, 1.0))

exampleRectangle.Fill = myBrush
<Rectangle Width="75" Height="75">
  <Rectangle.Fill>
    <RadialGradientBrush GradientOrigin="0.75,0.25">
      <GradientStop Color="Yellow" Offset="0.0" />
      <GradientStop Color="Orange" Offset="0.5" />
      <GradientStop Color="Red" Offset="1.0" />
    </RadialGradientBrush>
  </Rectangle.Fill>
</Rectangle>

Per ulteriori informazioni sul RadialGradientBrush classe, vedere disegni con colori a tinta unita e sfumature Panoramica.For more information about the RadialGradientBrush class, see Painting with Solid Colors and Gradients Overview.

Disegno con un'immaginePaint with an Image

Un ImageBrush disegna un'area con un ImageSource.An ImageBrush paints an area with a ImageSource.

Nell'esempio seguente viene utilizzato un ImageBrush per disegnare il Fill di un Rectangle.The following example uses an ImageBrush to paint the Fill of a Rectangle. Nella figura seguente viene illustrato il rettangolo disegnato.The following illustration shows the painted rectangle.

Rettangolo disegnato usando ImageBrushA Rectangle painted by an ImageBrush
Rettangolo disegnato usando un'immagineA Rectangle painted using a Image

Rectangle exampleRectangle = new Rectangle();
exampleRectangle.Width = 75;
exampleRectangle.Height = 75;

// Create an ImageBrush and use it to
// paint the rectangle.
ImageBrush myBrush = new ImageBrush();
myBrush.ImageSource = 
    new BitmapImage(new Uri(@"sampleImages\pinkcherries.jpg", UriKind.Relative));

exampleRectangle.Fill = myBrush;
Dim exampleRectangle As New Rectangle()
exampleRectangle.Width = 75
exampleRectangle.Height = 75

' Create an ImageBrush and use it to
' paint the rectangle.
Dim myBrush As New ImageBrush()
myBrush.ImageSource = New BitmapImage(New Uri("sampleImages\pinkcherries.jpg", UriKind.Relative))

exampleRectangle.Fill = myBrush
<Rectangle Width="75" Height="75">
  <Rectangle.Fill>
    <ImageBrush ImageSource="sampleImages\pinkcherries.jpg"  />
  </Rectangle.Fill>
</Rectangle>

Per ulteriori informazioni sul ImageBrush classe, vedere il disegno di immagini, disegni e oggetti visivi.For more information about the ImageBrush class, see Painting with Images, Drawings, and Visuals.

Disegno con un disegnoPaint with a Drawing

Oggetto DrawingBrush disegna un'area con un Drawing.A DrawingBrush paints an area with a Drawing. Oggetto Drawing può contenere forme, immagini, testo e supporto.A Drawing can contain shapes, images, text, and media.

Nell'esempio seguente viene utilizzato un DrawingBrush per disegnare il Fill di un Rectangle.The following example uses a DrawingBrush to paint the Fill of a Rectangle. Nella figura seguente viene illustrato il rettangolo disegnato.The following illustration shows the painted rectangle.

Rettangolo disegnato usando DrawingBrushA rectangle painted using a DrawingBrush
Rettangolo disegnato usando DrawingBrushA Rectangle painted using a DrawingBrush

Rectangle exampleRectangle = new Rectangle();
exampleRectangle.Width = 75;
exampleRectangle.Height = 75;

// Create a DrawingBrush and use it to
// paint the rectangle.
DrawingBrush myBrush = new DrawingBrush();

GeometryDrawing backgroundSquare =
    new GeometryDrawing(
        Brushes.White,
        null,
        new RectangleGeometry(new Rect(0, 0, 100, 100)));

GeometryGroup aGeometryGroup = new GeometryGroup();
aGeometryGroup.Children.Add(new RectangleGeometry(new Rect(0, 0, 50, 50)));
aGeometryGroup.Children.Add(new RectangleGeometry(new Rect(50, 50, 50, 50)));

LinearGradientBrush checkerBrush = new LinearGradientBrush();
checkerBrush.GradientStops.Add(new GradientStop(Colors.Black, 0.0));
checkerBrush.GradientStops.Add(new GradientStop(Colors.Gray, 1.0));

GeometryDrawing checkers = new GeometryDrawing(checkerBrush, null, aGeometryGroup);

DrawingGroup checkersDrawingGroup = new DrawingGroup();
checkersDrawingGroup.Children.Add(backgroundSquare);
checkersDrawingGroup.Children.Add(checkers);

myBrush.Drawing = checkersDrawingGroup;
myBrush.Viewport = new Rect(0, 0, 0.25, 0.25);
myBrush.TileMode = TileMode.Tile;

exampleRectangle.Fill = myBrush;
Dim exampleRectangle As New Rectangle()
exampleRectangle.Width = 75
exampleRectangle.Height = 75

' Create a DrawingBrush and use it to
' paint the rectangle.
Dim myBrush As New DrawingBrush()

Dim backgroundSquare As New GeometryDrawing(Brushes.White, Nothing, New RectangleGeometry(New Rect(0, 0, 100, 100)))

Dim aGeometryGroup As New GeometryGroup()
aGeometryGroup.Children.Add(New RectangleGeometry(New Rect(0, 0, 50, 50)))
aGeometryGroup.Children.Add(New RectangleGeometry(New Rect(50, 50, 50, 50)))

Dim checkerBrush As New LinearGradientBrush()
checkerBrush.GradientStops.Add(New GradientStop(Colors.Black, 0.0))
checkerBrush.GradientStops.Add(New GradientStop(Colors.Gray, 1.0))

Dim checkers As New GeometryDrawing(checkerBrush, Nothing, aGeometryGroup)

Dim checkersDrawingGroup As New DrawingGroup()
checkersDrawingGroup.Children.Add(backgroundSquare)
checkersDrawingGroup.Children.Add(checkers)

myBrush.Drawing = checkersDrawingGroup
myBrush.Viewport = New Rect(0, 0, 0.25, 0.25)
myBrush.TileMode = TileMode.Tile

exampleRectangle.Fill = myBrush
<Rectangle Width="75" Height="75">
  <Rectangle.Fill>
    <DrawingBrush Viewport="0,0,0.25,0.25" 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>
</Rectangle>

Per ulteriori informazioni sul DrawingBrush classe, vedere il disegno di immagini, disegni e oggetti visivi.For more information about the DrawingBrush class, see Painting with Images, Drawings, and Visuals.

Disegno con un oggetto visivoPaint with a Visual

Oggetto VisualBrush disegna un'area con un Visual oggetto.A VisualBrush paints an area with a Visual object. Esempi di oggetti visivi Button, Page, e MediaElement.Examples of Visual objects include Button, Page, and MediaElement. Oggetto VisualBrush consente inoltre di contenuto del progetto da una parte dell'applicazione in un'altra area; è molto utile per la creazione di effetti di reflection e ingrandimento delle parti dello schermo.A VisualBrush also enables you to project content from one portion of your application into another area; it's very useful for creating reflection effects and magnifying portions of the screen.

Nell'esempio seguente viene utilizzato un VisualBrush per disegnare il Fill di un Rectangle.The following example uses a VisualBrush to paint the Fill of a Rectangle. Nella figura seguente viene illustrato il rettangolo disegnato.The following illustration shows the painted rectangle.

Rettangolo disegnato usando VisualBrushA rectangle painted using a VisualBrush
Rettangolo disegnato usando VisualBrushA Rectangle painted using a VisualBrush

Rectangle exampleRectangle = new Rectangle();
exampleRectangle.Width = 75;
exampleRectangle.Height = 75;

// Create a VisualBrush and use it
// to paint the rectangle.
VisualBrush myBrush = new VisualBrush();

//
// Create the brush's contents.
//
StackPanel aPanel = new StackPanel();

// Create a DrawingBrush and use it to
// paint the panel.
DrawingBrush myDrawingBrushBrush = new DrawingBrush();
GeometryGroup aGeometryGroup = new GeometryGroup();
aGeometryGroup.Children.Add(new RectangleGeometry(new Rect(0, 0, 50, 50)));
aGeometryGroup.Children.Add(new RectangleGeometry(new Rect(50, 50, 50, 50)));
RadialGradientBrush checkerBrush = new RadialGradientBrush();
checkerBrush.GradientStops.Add(new GradientStop(Colors.MediumBlue, 0.0));
checkerBrush.GradientStops.Add(new GradientStop(Colors.White, 1.0));
GeometryDrawing checkers = new GeometryDrawing(checkerBrush, null, aGeometryGroup);
myDrawingBrushBrush.Drawing = checkers;
aPanel.Background = myDrawingBrushBrush;

// Create some text.
TextBlock someText = new TextBlock();
someText.Text = "Hello, World";
FontSizeConverter fSizeConverter = new FontSizeConverter();
someText.FontSize = (double)fSizeConverter.ConvertFromString("10pt");
someText.Margin = new Thickness(10);

aPanel.Children.Add(someText);

myBrush.Visual = aPanel;
exampleRectangle.Fill = myBrush;

Dim exampleRectangle As New Rectangle()
exampleRectangle.Width = 75
exampleRectangle.Height = 75

' Create a VisualBrush and use it
' to paint the rectangle.
Dim myBrush As New VisualBrush()

'
' Create the brush's contents.
'
Dim aPanel As New StackPanel()

' Create a DrawingBrush and use it to
' paint the panel.
Dim myDrawingBrushBrush As New DrawingBrush()
Dim aGeometryGroup As New GeometryGroup()
aGeometryGroup.Children.Add(New RectangleGeometry(New Rect(0, 0, 50, 50)))
aGeometryGroup.Children.Add(New RectangleGeometry(New Rect(50, 50, 50, 50)))
Dim checkerBrush As New RadialGradientBrush()
checkerBrush.GradientStops.Add(New GradientStop(Colors.MediumBlue, 0.0))
checkerBrush.GradientStops.Add(New GradientStop(Colors.White, 1.0))
Dim checkers As New GeometryDrawing(checkerBrush, Nothing, aGeometryGroup)
myDrawingBrushBrush.Drawing = checkers
aPanel.Background = myDrawingBrushBrush

' Create some text.
Dim someText As New TextBlock()
someText.Text = "Hello, World"
Dim fSizeConverter As New FontSizeConverter()
someText.FontSize = CDbl(fSizeConverter.ConvertFromString("10pt"))
someText.Margin = New Thickness(10)

aPanel.Children.Add(someText)

myBrush.Visual = aPanel
exampleRectangle.Fill = myBrush

<Rectangle Width="75" Height="75">
  <Rectangle.Fill>
    <VisualBrush TileMode="Tile">
      <VisualBrush.Visual>
        <StackPanel>
          <StackPanel.Background>
            <DrawingBrush>
              <DrawingBrush.Drawing>
                <GeometryDrawing>
                  <GeometryDrawing.Brush>
                    <RadialGradientBrush>
                      <GradientStop Color="MediumBlue" Offset="0.0" />
                      <GradientStop Color="White" Offset="1.0" />
                    </RadialGradientBrush>
                  </GeometryDrawing.Brush>
                  <GeometryDrawing.Geometry>
                    <GeometryGroup>
                      <RectangleGeometry Rect="0,0,50,50" />
                      <RectangleGeometry Rect="50,50,50,50" />
                    </GeometryGroup>
                  </GeometryDrawing.Geometry>
                </GeometryDrawing>
              </DrawingBrush.Drawing>
            </DrawingBrush>
          </StackPanel.Background>
          <TextBlock FontSize="10pt" Margin="10">Hello, World!</TextBlock>
        </StackPanel>
      </VisualBrush.Visual>
    </VisualBrush>
  </Rectangle.Fill>
</Rectangle>

Per ulteriori informazioni sul VisualBrush classe, vedere il disegno di immagini, disegni e oggetti visivi.For more information about the VisualBrush class, see Painting with Images, Drawings, and Visuals.

Disegnare con pennelli di sistema e predefinitiPaint using Predefined and System Brushes

Per praticità, Windows Presentation Foundation (WPF) fornisce un set di pennelli predefiniti e sistema che è possibile utilizzare per disegnare oggetti.For convenience, Windows Presentation Foundation (WPF) provides a set of predefined and system brushes that you can use to paint objects.

Funzionalità comuni dei pennelliCommon Brush Features

Brush gli oggetti forniscono un Opacity proprietà che può essere usato per rendere un pennello trasparente o semitrasparente.Brush objects provide an Opacity property that can be used to make a brush transparent or partially transparent. Un Opacity valore pari a 0 rende un pennello completamente trasparente, mentre un Opacity valore pari a 1 lo rende completamente opaco.An Opacity value of 0 makes a brush completely transparent, while an Opacity value of 1 makes a brush completely opaque. L'esempio seguente usa il Opacity proprietà per rendere un SolidColorBrush pari al 25%.The following example uses the Opacity property to make a SolidColorBrush 25 percent opaque.

<Rectangle Width="100" Height="100">
  <Rectangle.Fill>
    <SolidColorBrush Color="Blue" Opacity="0.25" />
  </Rectangle.Fill>
</Rectangle>
Rectangle myRectangle = new Rectangle();
myRectangle.Width = 100;
myRectangle.Height = 100;
SolidColorBrush partiallyTransparentSolidColorBrush
    = new SolidColorBrush(Colors.Blue);
partiallyTransparentSolidColorBrush.Opacity = 0.25;
myRectangle.Fill = partiallyTransparentSolidColorBrush;

Se il pennello contiene colori parzialmente trasparenti, viene combinato, il valore di opacità del colore tramite moltiplicazione con il valore di opacità del pennello.If the brush contains colors that are partially transparent, the opacity value of the color is combined through multiplication with the opacity value of the brush. Ad esempio, se un pennello ha un valore di opacità pari a 0,5 e un colore utilizzato per il pennello ha anche un valore di opacità pari a 0,5, il colore di output ha un valore di opacità 0.25.For example, if a brush has an opacity value of 0.5 and a color used in the brush also has an opacity value of 0.5, the output color has an opacity value of 0.25.

Nota

È più efficiente per modificare il valore di opacità di un pennello, piuttosto che modifica l'opacità di un elemento intero utilizzando il relativo UIElement.Opacity proprietà.It's more efficient to change the opacity value of a brush than it is to change the opacity of an entire element using its UIElement.Opacity property.

Ruotare, ridimensionare, inclinare e traslare il contenuto di un pennello utilizzando il relativo Transform o RelativeTransform proprietà.You can rotate, scale, skew, and translate a brush's content by using its Transform or RelativeTransform properties. Per ulteriori informazioni, vedere Brush Transformation Overview.For more information, see Brush Transformation Overview.

Poiché si tratta di Animatable oggetti Brush oggetti possono essere animati.Because they are Animatable objects, Brush objects can be animated. Per altre informazioni, vedere Panoramica dell'animazione.For more information, see Animation Overview.

Funzionalità di FreezableFreezable Features

Perché eredita dal Freezable (classe), il Brush classe fornisce diverse funzionalità speciali: Brush gli oggetti possono essere dichiarati come risorse, condivisi tra più oggetti e duplicati.Because it inherits from the Freezable class, the Brush class provides several special features: Brush objects can be declared as resources, shared among multiple objects, and cloned. Inoltre, tutti i Brush tranne i tipi VisualBrush può essere resa di sola lettura per migliorare le prestazioni e resi thread-safe.In addition, all the Brush types except VisualBrush can be made read-only to improve performance and made thread-safe.

Per ulteriori informazioni sulle diverse funzionalità fornite da Freezable degli oggetti, vedere panoramica sugli oggetti Freezable.For more information about the different features provided by Freezable objects, see Freezable Objects Overview.

Per ulteriori informazioni sui motivi per cui VisualBrush oggetti non possono essere bloccati, vedere il VisualBrush pagina di tipo.For more information on why VisualBrush objects cannot be frozen, see the VisualBrush type page.

Vedere ancheSee Also

Brush
Brushes
Cenni sul disegno con colori a tinta unita e sfumaturePainting with Solid Colors and Gradients Overview
Disegnare con oggetti Image, Drawing e VisualPainting with Images, Drawings, and Visuals
Cenni preliminari sugli oggetti FreezableFreezable Objects Overview
Brushes Sample (Esempio di pennelli)Brushes Sample
Esempio ImageBrushImageBrush Sample
Esempio VisualBrushVisualBrush Sample
Procedure relative alle proprietàHow-to Topics
Altri suggerimenti relativi alle prestazioniOther Performance Recommendations