Basic Drawing and Shapes in Windows Presentation Foundation
article covers the new features introduced in Windows Presentation Foundation
for drawing shapes. A Shape is a type of UIElement, and enables you to draw a
shape to the screen. The Content Panels can contain Shape elements as children.
Whenever the properties of these elements got changed, screen reflects those changes
provides number of Shape classes. These are derived from Shape class.
Line, Path, Polygon, Polyline, and Rectangle are few classes derived from Shape
class. The WPF also defines 3DGementric shapes. The user can define any 3D shape
by specifying collection triangular surfaces in 3D space.
class has following properties:
Stroke - StrokeThickness - Fill - Data
Stretch : Specify the behavior of the shapes, when the width and height of Parent
element got changed. The following are values
'Stretch' property : None
- Fill - Uniform - UniformToFill
Transformation : Specify the type and measure for transformation
- Centre, Angle
ScaleTransform - Origin, scale factor
SkewTransform - Tilting
TranslateTransform - Displacement in x and y
example below defines a line and polyline elements with a stretch to fill and
10 deg rotation.
Points="100,100 100,200 200,200 200,100"
<RotateTransform Angle="10" />
result of the above code will give you an image as shown below:
you can use the shape object to draw the shapes. You can access the different
graphics and rendering services that are available in the Windows Presentation
to our mailing list and receive new articles
through email. Keep yourself updated with latest
developments in the industry.
: We never rent, trade, or sell my email lists to
We assure that your privacy is respected
.NET Programming Tutorial Homepage