TileMode Enumeration
Describes how a TileBrush paints tiles onto an output area.
Assembly: PresentationCore (in PresentationCore.dll)
| Member name | Description | |
|---|---|---|
| None | The base tile is drawn but not repeated. The remaining area is transparent | |
| Tile | The base tile is drawn and the remaining area is filled by repeating the base tile. The right edge of one tile meets the left edge of the next, and similarly for the bottom and top edges. | |
| FlipX | The same as Tile except that alternate columns of tiles are flipped horizontally. The base tile itself is not flipped. | |
| FlipY | The same as Tile except that alternate rows of tiles are flipped vertically. The base tile itself is not flipped. | |
| FlipXY | The combination of FlipX and FlipY. The base tile itself is not flipped. |
This example shows how to use the TileMode property of a TileBrush to create a pattern.
The TileMode property enables you to specify how the content of a TileBrush is repeated, that is, tiled to fill an output area. To create a pattern, you set the TileMode to Tile, FlipX, FlipY, or FlipXY. You must also set the Viewport of the TileBrush so that it is smaller than the area that you are painting; otherwise, only a single tile is produced, regardless which TileMode setting you use.
The following example creates five DrawingBrush objects, gives them each a different TileMode setting, and uses them to paint five rectangles. Although this example uses the DrawingBrush class to demonstrate TileMode behavior, the TileMode property works identically for all the TileBrush objects, that is, for ImageBrush, VisualBrush, and DrawingBrush.
The following illustration shows the output that this example produces.

<!-- Demonstrates TileMode values. --> <Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:PresentationOptions="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="PresentationOptions" Background="White" Margin="20"> <Page.Resources> <!-- Define a Drawing as a resource that it can be easily used as content for all the DrawingBrush objects in this example. --> <GeometryDrawing x:Key="TriangleDrawing" Geometry="M0,0 L50,0 0,50Z" Brush="#CCCCFF" PresentationOptions:Freeze="True" > <GeometryDrawing.Pen> <Pen Thickness="2" Brush="Black" MiterLimit="0" /> </GeometryDrawing.Pen> </GeometryDrawing> </Page.Resources> <StackPanel HorizontalAlignment="Left"> <TextBlock Margin="0,10,0,0">None</TextBlock> <Rectangle Width="50" Height="50" Stroke="Black" StrokeThickness="1"> <Rectangle.Fill> <!-- The DrawingBrush's content is not tiled in this example. --> <DrawingBrush TileMode="None" Drawing="{StaticResource TriangleDrawing}" /> </Rectangle.Fill> </Rectangle> <TextBlock Margin="0,10,0,0">Tile</TextBlock> <Rectangle Width="50" Height="50" Stroke="Black" StrokeThickness="1"> <Rectangle.Fill> <!-- The DrawingBrush's content is tiled in this example. The Viewport property is set to create four tiles. --> <DrawingBrush TileMode="Tile" Viewport="0,0,0.5,0.5" Drawing="{StaticResource TriangleDrawing}"/> </Rectangle.Fill> </Rectangle> <TextBlock Margin="0,10,0,0">FlipX</TextBlock> <Rectangle Width="50" Height="50" Stroke="Black" StrokeThickness="1"> <Rectangle.Fill> <!-- The DrawingBrush's content is flipped horizontally as it is tiled in this example. --> <DrawingBrush TileMode="FlipX" Viewport="0,0,0.5,0.5" Drawing="{StaticResource TriangleDrawing}" /> </Rectangle.Fill> </Rectangle> <TextBlock Margin="0,10,0,0">FlipY</TextBlock> <Rectangle Width="50" Height="50" Stroke="Black" StrokeThickness="1"> <Rectangle.Fill> <!-- The DrawingBrush's content is flipped vertically as it is tiled in this example. --> <DrawingBrush TileMode="FlipY" Viewport="0,0,0.5,0.5" Drawing="{StaticResource TriangleDrawing}" /> </Rectangle.Fill> </Rectangle> <TextBlock Margin="0,10,0,0">FlipXY</TextBlock> <Rectangle Width="50" Height="50" Stroke="Black" StrokeThickness="1"> <Rectangle.Fill> <!-- The DrawingBrush's content is flipped horizontally and vertically as it is tiled in this example. --> <DrawingBrush TileMode="FlipXY" Viewport="0,0,0.5,0.5" Drawing="{StaticResource TriangleDrawing}" /> </Rectangle.Fill> </Rectangle> </StackPanel> </Page>
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
