Assembly: PresentationCore (in presentationcore.dll)
XML Namespace: http://schemas.microsoft.com/winfx/2006/xaml/presentation
This example describes how to use the RectangleGeometry class to describe a rectangle.
The following example shows how to create and render a RectangleGeometry. The relative position and the dimensions of the rectangle are defined by a Rect structure. The relative position is 50,50 and the height and the width are both 25 creating a square. The rectangle's interior is painted with a LemonChiffon brush and its outline is painted with a Black stroke with a thickness of 1.
<Path Fill="LemonChiffon" Stroke="Black" StrokeThickness="1"> <Path.Data> <RectangleGeometry Rect="50,50,25,25" /> </Path.Data> </Path>
RectangleGeometry myRectangleGeometry = new RectangleGeometry(); myRectangleGeometry.Rect = new Rect(50,50,25,25); Path myPath = new Path(); myPath.Fill = Brushes.LemonChiffon; myPath.Stroke = Brushes.Black; myPath.StrokeThickness = 1; myPath.Data = myRectangleGeometry;
Although this example used a Path element to render the RectangleGeometry, there are many other ways to use RectangleGeometry objects. For example, a RectangleGeometry can be used to specify the Clip of a UIElement or the Geometry of a GeometryDrawing.
|How to: Round the Corners of a RectangleGeometry|
|How to: Animate a Rectangle Geometry by Using Key Frames|| |
This example shows how to animate the Rect property of a RectangleGeometry by using key frames.
|How to: Create a Composite Shape|| |
This example shows how to create composite shapes using Geometry objects and display them using a Path element. In the following example, a LineGeometry, EllipseGeometry, and a RectangleGeometry are used with a GeometryGroup to create a composite shape. The geometries are then drawn using a Path element.
|How to: Create a Shape by Using a PathGeometry|| |
This example shows how to create a shape using the PathGeometry class. PathGeometry objects are composed of one or more PathFigure objects; each PathFigure represents a different "figure" or shape. Each PathFigure is itself composed of one or more PathSegment objects, each representing a connected portion of the figure or shape. Segment types include LineSegment, ArcSegment, and BezierSegment.
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter EditionThe Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.