The 'Shapes' of XAML – Rectangles & Ellipses
Although you may not agree at first, you have many reasons to need to learn about XAML shapes, paths, and geometries. You’ll need to work with drawing fundamentals if you intend to:
- Create customized art
- Create custom controls
- Add interactivity to graphics
- Use animation
- Create any non-standard user interface
In this article, we'll look at Rectangle and Ellipse Shapes!
Rectangle and Ellipse Shapes
Shapes don’t get much simpler than those provided by the Rectangle and Ellipse classes. To use these shapes, supply any or all of the following properties:
- Height and Width to define the dimensions of the shape. (Using equal values for these properties creates a square or a circle, as opposed to a rectangle or an ellipse.)
- Stroke and Fill to define the visual characteristics of the shape.
- MinHeight and MinWidth to determine the minimum size in a dynamic, sizing container.
- Margin to determine the space around the shape.
- HorizontalAlignment and VerticalAlignment to determine the positioning of the shape within its container.
Select Rectangles and Ellipses from the main tab to view the output from the sample page, RectanglesAndEllipses.xaml, as shown in the Figure below. The following markup renders the output shown in the Figure below:
This post is an excerpt from the online courseware for our Windows 8 Using XAML: Bindings, Shapes, and Animation course written by expert Ken Getz.
Ken Getz is a Visual Studio expert with over 25 years of experience as a successful developer and consultant. He is a nationally recognized author and speaker, as well as a featured instructor for LearnNowOnline.
Thousands of developers worldwide use LearnNowOnline to gain the technical skills they need to succeed on the job and advance their career.