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)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public bool ClipToBounds { get; set; }
/** @property */
public boolean get_ClipToBounds ()

/** @property */
public void set_ClipToBounds (boolean value)

public function get ClipToBounds () : boolean

public function set ClipToBounds (value : boolean)

<object ClipToBounds="bool" .../>

Property Value

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

Identifier field


Metadata properties set to true


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.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions