Export (0) Print
Expand All

TileBrush.Viewport Property

Gets or sets the position and dimensions of the base tile for a TileBrush.

Namespace:  System.Windows.Media
Assembly:  PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

public Rect Viewport { get; set; }
<object>
  <object.Viewport>
    <Rect .../>
  </object.Viewport>
</object>
<object Viewport="Rect" .../>

Property Value

Type: System.Windows.Rect
The position and dimensions of the base tile for a TileBrush. The default value is a rectangle (Rect) with a TopLeft of (0,0) and a Width and Height of 1.

Identifier field

ViewportProperty

Metadata properties set to true

None

When you paint an area by using a TileBrush, you use three components: content, tiles, and the output area. The following illustration shows how these three TileBrush components relate to each other.

Components of a TileBrush with a single tile

TileBrush components
Components of a TileBrush with a TileMode of Tile

Components of a tiled TileBrush

The Viewport property determines the size and position of the tiles in a TileBrush. By default, a TileBrush has a single tile that fills the whole output area. The Stretch property controls how the TileBrush content fits into that tile. You can override this default behavior and specify the tile size by using the Viewport property.

Use the ViewportUnits property to specify whether the Viewport uses absolute or relative coordinates. If the coordinates are relative, they are relative to the size of the output area. The point (0,0) represents the upper-left corner of the output area, and (1,1) represents the lower-right corner of the output area. To specify that the Viewport property uses absolute coordinates, set the ViewportUnits property to Absolute.

The following illustration shows the difference in output when you set the ViewportUnits property of a TileBrush to either relative or absolute.

Relative and absolute ViewportUnits

Absolute and Relative Viewport Units

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft