SIGN UP MEMBER LOGIN:    
ARTICLE

Silverlight Border Control

Posted by Raj Kumar Articles | Learn .NET October 17, 2008
This article describes how to use Silverlight Border control.
Reader Level:

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.

 

Login to add your contents and source code to this article
share this article :
post comment
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Team Foundation Server Hosting
Become a Sponsor