StrokeCollection.GetBounds 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
回傳集合中筆劃的界限。
public:
System::Windows::Rect GetBounds();
public System.Windows.Rect GetBounds();
member this.GetBounds : unit -> System.Windows.Rect
Public Function GetBounds () As Rect
傳回
Rect A 包含 中筆劃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 方法回傳 a Rect 呈現渲染 的外觀 Stroke。 例如,若 Stroke 寬 10 個顯示無關像素(DIP),則Rect包含整個寬度。Stroke