共用方式為


StrokeCollection.GetBounds 方法

定義

傳回集合中筆劃的界限。

public:
 System::Windows::Rect GetBounds();
public System.Windows.Rect GetBounds ();
member this.GetBounds : unit -> System.Windows.Rect
Public Function GetBounds () As Rect

傳回

Rect

Rect,包含 StrokeCollection 中筆劃的界限。

範例

下列範例示範如何取得 的 StrokeCollection 界限,並將其繪製在 控制項上。 此範例假設有 InkCanvas 名為 inkCanvas1 的 。

public void GetBounds()
{
    Rect bounds = inkCanvas1.Strokes.GetBounds();

    Rectangle boundsShape = new Rectangle();
    boundsShape.Width = bounds.Width;
    boundsShape.Height = bounds.Height;
    boundsShape.Stroke = Brushes.Red;

    InkCanvas.SetTop(boundsShape, bounds.Top);
    InkCanvas.SetLeft(boundsShape, bounds.Left);

    inkCanvas1.Children.Add(boundsShape);
}
Public Sub GetBounds()
    Dim bounds As Rect = inkCanvas1.Strokes.GetBounds()

    Dim boundsShape As Rectangle = New Rectangle()
    boundsShape.Width = bounds.Width
    boundsShape.Height = bounds.Height
    boundsShape.Stroke = Brushes.Red

    InkCanvas.SetTop(boundsShape, bounds.Top)
    InkCanvas.SetLeft(boundsShape, bounds.Left)

    inkCanvas1.Children.Add(boundsShape)
End Sub

備註

方法 GetBounds 會傳 Rect 回 ,其外觀為呈現 Stroke 的 。 例如,如果 Stroke 為 10 顯示獨立圖元, (DIP) 寬,則 Rect 包含 的整個寬度 Stroke

適用於