ContainerVisual.ContentBounds 属性

定义

获取 ContainerVisual 内容的边界框。

public:
 property System::Windows::Rect ContentBounds { System::Windows::Rect get(); };
public System.Windows.Rect ContentBounds { get; }
member this.ContentBounds : System.Windows.Rect
Public ReadOnly Property ContentBounds As Rect

属性值

Rect

一个指定边界框的 Rect

示例

下面的示例演示如何检索对象的边界矩形 ContainerVisual

// Return the bounding rectangle for the ContainerVisual.
Rect rectBounds = containerVisual.ContentBounds;

// Expand the rectangle to include the bounding rectangle
// of the all of the ContainerVisual's descendants.
rectBounds.Union(containerVisual.DescendantBounds);
' Return the bounding rectangle for the ContainerVisual.
Dim rectBounds As Rect = containerVisual.ContentBounds

' Expand the rectangle to include the bounding rectangle
' of the all of the ContainerVisual's descendants.
rectBounds.Union(containerVisual.DescendantBounds)

注解

DescendantBounds使用属性可返回对象的所有后代ContainerVisual的所有内容边界框的联合,但不能返回对象本身。

适用于