Pages

Tuesday, 12 March 2013

Rectangle Control in WPF

Rectangle Control in WPF Window Based

Rectangle Means From Latin: rectus "right" + angle A 4-sided polygon where all interior angles are 90° The rectangle, like the square, is one of the most commonly known quadrilaterals. It is defined as having all four interior angles 90° (right angles). The Rectangle object represents a rectangle shape and draws a rectangle with the given height and width. The <Rectangle /> element of  XAML draws a rectangle. The Height and Width attributes represent the height and width of the rectangle. The Stroke and StrokeThickness represents the color and thickness of the rectangle boundary.

Example:

XAML Code:

<Window x:Class="WpfApplication7.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="312" Width="240" Loaded="Window_Loaded">
    <Grid>
     <Rectangle Margin="14,40,0,0" Name="rectangle1" Stroke="Violet" StrokeThickness="9" Height="100" 
     VerticalAlignment="Top" HorizontalAlignment="Left" Width="200" Fill="Pink" RadiusX="6" RadiusY="6" />
    </Grid>
</Window> 
 
in This code The Fill attributes fill a rectangle with a color. The following code fills a rectangle with pink color.
By setting RadiusX and RadiusY attributes, you can also draw a rectangle with rounded corders.

Output:

No comments:

Post a Comment