UIElement.ClipToBounds 屬性

定義

取得或設定是否裁剪此元素 (或來自此元素的子元素) 的內容,以符合容器元素大小的值。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

屬性值

如果應該裁剪內容即為 true;否則為 falsetrue if the content should be clipped; otherwise, false. 預設值是 falseThe default value is false.

備註

對於子專案,ClipToBounds 在版面配置行為上有不同的效果,這取決於父元素的高度和寬度是否由 Height / WidthMaxHeight / MaxWidth決定。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. 不論 ClipToBounds 的值為何,一律會遵守父元素的 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. falseClipToBounds 時,父系的 Height / Width 設定不會裁剪內容,但如果 ClipToBoundstrue,則會裁剪內容。The parent's Height / Width settings will not clip the content when ClipToBounds is false, but will clip the content if ClipToBounds is true.

請注意,預設為 false 是在 UIElement 類別中實作為實作為執行方式的一般行為。Note that defaulting to false is the general behavior as implemented in the UIElement class. 任何衍生自 UIElement 的指定專案,都可以覆寫該實例中這個屬性的相依性屬性中繼資料,改為預設為 trueIt 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.

InkCanvasInkPresenterPopup 會覆寫要 true的預設值。InkCanvas, InkPresenter, and Popup each override the default value to be true.

FrameworkElement 會覆寫此相依性屬性的中繼資料。FrameworkElement overrides the metadata for this dependency property. 具體而言,FrameworkElement 指定此屬性,以允許屬性值繼承(Inherits 在中繼資料中 true)。Specifically, FrameworkElement designates this property to allow property value inheritance (Inherits is true in metadata). 此內容中的屬性值繼承表示,如果 ClipToBounds 透過本機值或樣式指派的子項目沒有其他值,則最接近的父項目值會被指派(同樣是在樣式、預設值或本機值),而父元素的值將會由屬性系統指派給所有未指派的子項目。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. 實際上,這表示您可以指定是否允許在根項目上使用裁剪至界限,而該值將會傳播至尚未特別指派為 false的所有子項目。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

識別碼欄位Identifier field ClipToBoundsProperty
設定為 true 的中繼資料屬性Metadata properties set to true None

適用於

另請參閱