TileBrush::TileMode Property
Gets or sets a value that specifies how a TileBrush fills the area that you are painting if the base tile is smaller than the output area.
Assembly: PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
<object TileMode="TileMode" .../>
Property Value
Type: System.Windows.Media::TileModeA value that specifies how the TileBrush tiles fill the output area when the base tile, which is specified by the Viewport property, is smaller than the output area. The default value is None.
The following illustration shows the different tile modes, which are defined by the TileMode enumeration.

For the TileMode property to have an effect, you must set the Viewport for the brush to a size that is smaller than the area that you are painting (the output area). If the Viewport size is equal to or exceeds the output area, the brush produces a single tile that expands to fill the output area, and no tile pattern occurs.
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>
More Code
| How to: Paint an Area with an Image | This example shows how to use the ImageBrush class to paint an area with an image. An ImageBrush displays a single image, which is specified by its ImageSource property. |
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.