UIElement.ClipToBounds Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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.
public:
property bool ClipToBounds { bool get(); void set(bool value); };
public bool ClipToBounds { get; set; }
member this.ClipToBounds : bool with get, set
Public Property ClipToBounds As Boolean
Property Value
true
if the content should be clipped; otherwise, false
. The default value is false
.
Remarks
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
.
Dependency Property Information
Item | Value |
---|---|
Identifier field | ClipToBoundsProperty |
Metadata properties set to true |
None |
Applies to
See also
.NET