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

屬性值

Boolean

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

備註

針對子項目, ClipToBounds 根據或的父元素的高度和寬度,對版面配置行為有不同的效果 Height / Width MaxHeight / MaxWidthFor 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 無論的值為何,一律都會遵守父項目的 ClipToBounds ,且有效的裁剪一律會根據這些最大值來裁剪內容。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. Height / Width 當為時,父系的設定不會裁剪 ClipToBounds 內容 false ,但如果是,則會裁剪內容 ClipToBounds trueThe parent's Height / Width settings will not clip the content when ClipToBounds is false, but will clip the content if ClipToBounds is true.

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

InkCanvasInkPresenter 和都會將 Popup 預設值覆寫為 trueInkCanvas, 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. 在實務上,這表示您可以指定是否在根項目上允許剪輯至界限,而該值將會傳播至尚未明確指派為的所有子項目 falseIn 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
中繼資料屬性設定為 trueMetadata properties set to true NoneNone

適用於

另請參閱