.NET Framework Class Library for Silverlight
UIElement..::.Clip Property

Gets or sets the Geometry used to define the outline of the contents of a UIElement.

Namespace:  System.Windows
Assembly:  System.Windows (in System.Windows.dll)
Syntax

Visual Basic (Declaration)
Public Property Clip As Geometry
    Get
    Set
Visual Basic (Usage)
Dim instance As UIElement
Dim value As Geometry

value = instance.Clip

instance.Clip = value
C#
public Geometry Clip { get; set; }
XAML Property Element Usage
<uiElement>
  <uiElement.Clip>
    singleGeometry
  </uiElement.Clip>
</uiElement>

XAML Values

singleGeometry

Exactly one object element for an object that derives from Geometry. This is typically one of the classes defined by Silverlight: EllipseGeometry, GeometryGroup, LineGeometry, PathGeometry, RectangleGeometry.

Property Value

Type: System.Windows.Media..::.Geometry
The geometry to be used for clipping area sizing. The default value is nullNothingnullptra null reference (Nothing in Visual Basic).
Remarks

Dependency property identifier field: ClipProperty

A UIElement outside the geometry will be visually clipped in the rendered layout. The geometry does not have to be rectangular.

The clipped area is the "outside" of the geometry. In other words, the content that is shown (not clipped) is the area of the geometry that would otherwise have a Fill if the geometry were used as data for a Path rather than for clipping. The clipped area is any area that falls outside the geometry overlay. For complex geometries, the areas that are clipped or not clipped are influenced by the geometry's FillRule.

Clipping with a LineGeometry by itself would result in total clipping, because the line by itself has no dimension. EllipseGeometry, GeometryGroup, or RectangleGeometry are probably the simplest to use, but it is possible to use a PathGeometry for more complex results.

You can specify a complex geometry for Clip if you specify a single GeometryGroup as the value and populate the group with child geometries

An alternative approach for showing only part of a UIElement visually is to use OpacityMask, using either a RadialGradientBrush or an ImageBrush that uses a transparency mask. If you use the OpacityMask technique, you can create "bleed" effects against the background. The Clip technique always results in hard edges where the clip is applied.

For example code, see How to: Crop an Object.

Examples

For a XAML example, see How to: Crop an Object.

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

See Also

Reference

Other Resources

Tags :


Page view tracker