Pages

Sunday, 10 March 2013

Border Control in WPF

Border Control In WPF

The controls in WPF do not have border property so WPF provides a border control. Similar to other WPF elements, the Border has Width, Height, Background, and Horizontal Alignment and Vertical Alignment properties. Besides these common properties, Border has two properties that make Border a border.
  • BorderThickness -The BorderThickness property represents the thickness of the border.
  • BorderBrush.- The BorderBrush property represents the brush that is used to draw the border.
The Corner Radius property represents the degree to which the corners of a Border are rounded.
 

Code for Border-

<Window x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300">
    <Grid>
        <Border BorderThickness="5"
    BorderBrush="Green"
    CornerRadius="10"
    Background="LightGray"
    HorizontalAlignment="Left"
    VerticalAlignment="Top"
    Width="270"
    Height="250">
            <Canvas Background="LightCyan" >
                <Rectangle Canvas.Left="30" Canvas.Top="20"
                     Height="200" Width="200"
            Stroke="Black" StrokeThickness="10" Fill="Red" />
            </Canvas>
        </Border>
    </Grid>
</Window> 
 
Output will like this-

No comments:

Post a Comment