Export (0) Print
Expand All

UIElement.ClipToBounds Property

Gets or sets a value indicating whether to clip the content of this element (or content coming from the child elements of this element) to fit into the size of the containing element. This is a dependency property.

Namespace:  System.Windows
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 bool ClipToBounds { get; set; }
<object ClipToBounds="bool" .../>

Property Value

Type: System.Boolean
true if the content should be clipped; otherwise, false. The default value is false.

Identifier field

ClipToBoundsProperty

Metadata properties set to true

None

For child elements, ClipToBounds has different effects on layout behaviors depending on whether the height and width of the parent element are being determined by Height / Width or MaxHeight / MaxWidth. MaxHeight / MaxWidth of the parent element are always respected regardless of the value of ClipToBounds and the effective clipping will always clip the content based on these maximums. The parent's Height / Width settings will not clip the content when ClipToBounds is false, but will clip the content if ClipToBounds is true.

Note that defaulting to false is the general behavior as implemented in the UIElement class. It is possible for any given element that derives from UIElement to override the dependency property metadata for this property in that instance to default to true instead. Several existing derived classes override this metadata and/or adjust the dependency property default value.

InkCanvas, InkPresenter, and Popup each override the default value to be true.

FrameworkElement overrides the metadata for this dependency property. Specifically, FrameworkElement designates this property to allow property value inheritance (Inherits is true in metadata). Property value inheritance in this context means that if there are child elements with no other value for ClipToBounds assigned through local values or styles, the value of the nearest parent element with this value assigned (again, either in styles, by default values, or a locally value), then the value from the parent element will be assigned to all unassigned child elements by the property system. In practice this means that you can specify whether to allow clip to bounds at the root element, and that value will propagate to all child elements that have not specifically assigned it as false.

.NET Framework

Supported in: 4.5.3, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft