Silverlight Border Control


Border is a silver light control is used to put border to controls, text, and images.

<!--Border with CornerRadius property -->
<Border CornerRadius="10" BorderBrush="DarkGreen" Width="200" VerticalAlignment="Center" HorizontalAlignment="Center" BorderThickness="2"  Margin="2,2,2,2" Grid.Row="0" Grid.Column="0">
<TextBlock Text="Border Example" Margin="50,2,2,2" ></TextBlock>
</Border>



Figure1.

<!--Border -->
<Border BorderBrush="DarkGreen" Width="200" Height="150" BorderThickness="4" Margin="2,2,2,2" Grid.Row="1" Grid.Column="0">
</Border>



Figure2.

<!--Border with Brush -->
<Border x:Name="ex" BorderThickness="4" Width="200" Height="150" Grid.Row="2" Grid.Column="0" CornerRadius="10">

<Border.BorderBrush>
<
LinearGradientBrush x:Name="borderLinearGradientBrush" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0" EndPoint="0.5,1">

                    <LinearGradientBrush.GradientStops>
                        <GradientStop Color="Red" Offset="0" />
                        <GradientStop Color="Purple" Offset="                   

</
LinearGradientBrush.GradientStops>
                </LinearGradientBrush>
            </Border.BorderBrush
</Border>



Figure3.

<!--Border with ImageBrush -->
<Border CornerRadius="20" x:Name="border1" BorderBrush="Black" BorderThickness="4" Width="300" Height="250" Grid.Row="3" Grid.Column="0">
             <Border.Background>
                <ImageBrush x:Name="backgroundImageBrush" Stretch="UniformToFill">
                     <ImageBrush.ImageSource>
                        <BitmapImage x:Name="img" UriSource="Raj 039.JPG">
                        </BitmapImage>
                    </ImageBrush.ImageSource>
                </ImageBrush>
           </Border.Background>
        </Border>


Figure4.

<!-- Border with MouseLeave and MouseLeftButtonDown click-->
        <Border x:Name="ClickBorder" BorderThickness="2" Grid.Row="0" Grid.Column="1" >
           <Border.BorderBrush>
                <SolidColorBrush Color="Green" Opacity="0" />
            </Border.BorderBrush>
            <TextBlock
              MouseLeftButtonDown="TextBlock_MouseLeftButtonDown"   MouseLeave="TextBlock_MouseLeave"
              Text="RAJ BENIWAL" />
        </Border>

private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            ClickBorder.BorderBrush.Opacity = 1;
        }

        private void TextBlock_MouseLeave(object sender, MouseEventArgs e)
        {
            ClickBorder.BorderBrush.Opacity = 0;
        }



Figure5.


Figure6.

 


Similar Articles