Rect.Top 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
사각형 위쪽의 y축 좌표를 가져옵니다.
public:
property double Top { double get(); };
public double Top { get; }
member this.Top : double
Public ReadOnly Property Top As Double
속성 값
사각형 위쪽의 y축 좌표입니다.
예제
다음 예제에서는 코드를 사용 하 여 사각형을 만들고 페이지에 추가 하는 방법을 보여 줍니다. 이 예제에서는 새 사각형에 대 한 크기 및 좌표 정보를 찾아의 정보를 렌더링 하는 방법을 보여 줍니다는 TextBox 사각형 아래의 합니다.
// Create a rectangle and add it to the page. Also,
// find size and coordinate information about this
// new rectangle and render information in a TextBox
// below the rectangle.
private StackPanel createRectExample1()
{
// Initialize new rectangle.
Rect myRectangle = new Rect();
// The Location property specifies the coordinates of the upper left-hand
// corner of the rectangle. Set the Location property to an X coordinate of 10 and a
// Y coordinate of 5.
myRectangle.Location = new Point(10, 5);
// Set the Size property of the rectangle with a width of 200
// and a height of 50.
myRectangle.Size = new Size(200, 50);
RectangleGeometry myRectangleGeometry = new RectangleGeometry();
myRectangleGeometry.Rect = myRectangle;
// This path is defined by the rectangle.
Path myPath = new Path();
myPath.Fill = Brushes.LemonChiffon;
myPath.Stroke = Brushes.Black;
myPath.StrokeThickness = 1;
myPath.Data = myRectangleGeometry;
//////////// Create string of rectangle property information /////////////
// This string will contain all the size and coordinate property
// information about the rectangle.
/////////////////////////////////////////////////////////////////////////
string rectInfo = "Rectangle Property Information: ";
// Bottom property gets the y-axis value of the bottom of the rectangle.
// For this rectangle the value is 55.
rectInfo = rectInfo + "Bottom: " + myRectangle.Bottom;
// BottomLeft property gets the coordinates of the bottom left corner of the rectangle.
// For this rectangle the value is 10,55.
rectInfo = rectInfo + "| BottomLeft: " + myRectangle.BottomLeft;
// BottomRight property gets the coordinates of the bottom right corner of the rectangle.
// For this rectangle the value is 210,55.
rectInfo = rectInfo + "| BottomRight: " + myRectangle.BottomRight;
// Height property gets or sets the height of the rectangle.
// For this rectangle the value is 50.
rectInfo = rectInfo + "| Height: " + myRectangle.Height;
// Width property gets or sets the width of the rectangle.
// For this rectangle the value is 200.
rectInfo = rectInfo + "| Width: " + myRectangle.Width;
// Left property gets the x-axis position of the left side of the rectangle which is
// equivalent to getting the rectangle's X property.
// For this rectangle the value is 10.
rectInfo = rectInfo + "| Left: " + myRectangle.Left;
// Location property gets or sets the position of the rectangle's top-left corner.
// For this rectangle the value is 10,5.
rectInfo = rectInfo + "| Location: " + myRectangle.Location;
// Right property gets the x-axis value of the right side of the rectangle.
// For this rectangle the value is 210.
rectInfo = rectInfo + "| Right: " + myRectangle.Right;
// Size property gets or sets the width and height of the rectangle.
// For this rectangle the value is 200,50.
rectInfo = rectInfo + "| Size: " + myRectangle.Size;
// Top property gets the y-axis position of the top of the rectangle which is
// equivalent to getting the rectangle's Y property.
// For this rectangle the value is 5.
rectInfo = rectInfo + "| Top: " + myRectangle.Top;
// TopLeft property gets the position of the top-left corner of the rectangle, which
// is equivalent to (X, Y).
// For this rectangle the value is 10,5.
rectInfo = rectInfo + "| TopLeft: " + myRectangle.TopLeft;
// TopRight property gets the position of the top-left corner of the rectangle, which
// is equivalent to (X + Width, Y).
// For this rectangle the value is 210,5.
rectInfo = rectInfo + "| TopRight: " + myRectangle.TopRight;
// X property gets or sets the location of the rectangle's left side.
// For this rectangle the value is 10.
rectInfo = rectInfo + "| X: " + myRectangle.X;
// Y property gets or sets the location of the rectangle's top side.
// For this rectangle the value is 5.
rectInfo = rectInfo + "| Y: " + myRectangle.Y;
//////// End of creating string containing rectangle property information ////////
// This StackPanel will contain the rectangle and TextBlock.
StackPanel parentPanel = new StackPanel();
// Add the rectangle path to the StackPanel. This will display the rectangle.
parentPanel.Children.Add(myPath);
// Add a TextBlock to display the rectangle's size and coordinate information.
TextBlock myTextBlock = new TextBlock();
myTextBlock.Text = rectInfo;
parentPanel.Children.Add(myTextBlock);
// Return the parent container to be displayed to the screen.
return parentPanel;
}
설명
시작은이 속성은 Y 속성입니다.
적용 대상
추가 정보
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET