h1.post-title { color:orange; font-family:verdana,Arial; font-weight:bold; padding-bottom:5px; text-shadow:#64665b 0px 1px 1px; font-size:32px; } -->

Pages

WPF Day-2


Introduction:
    Yesterday we talked about WPF Introduction and AccessText Control. Today we will discuss about Board Control
·  Border Control:
  To draw a border, background or both around another elements.
Create Border in XAML:
<Border Background="CadetBlue"  BorderBrush="Blue" BorderThickness="5" CornerRadius="600" Padding="15">   </Border>
Create Border in Coding:
  Border myBorder;
     private void brder()
        {
            myBorder = new Border();
            myBorder.Background = Brushes.LightBlue;
            myBorder.BorderBrush = Brushes.Black;
            myBorder.BorderThickness = new Thickness(2);
            myBorder.CornerRadius = new CornerRadius(45);
            myBorder.Padding = new Thickness(25);
            this.Content = myBorder;
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            brder();
    }
Suppose, User wants to display a Child element in the Border.
This is the example.
Create Border in XAML:
        <Border  BorderThickness="5"   BorderBrush="Green"   CornerRadius="10"  Background="LightGray" HorizontalAlignment="Left" VerticalAlignment="Top" Width="270" Height="250">
        <Border  BorderThickness="1"   BorderBrush="Yellow"   CornerRadius="5"  Background="Blue"  HorizontalAlignment="Center"  VerticalAlignment="Center"  Width="150" Height="50">
        </Border>
        </Border>
Create Border in Coding:
         Border myBorder;
        Border myChildBorder;
    private void brder()
        {
            myBorder = new Border();
            myBorder.Background = Brushes.LightBlue;
            myBorder.BorderBrush = Brushes.Black;
            myBorder.BorderThickness = new Thickness(2);
            myBorder.CornerRadius = new CornerRadius(45);
            myBorder.Padding = new Thickness(25);
            myChildBorder = new Border();
            myChildBorder.Background = Brushes.DarkGreen;
            myChildBorder.BorderBrush = Brushes.Cyan;
            myChildBorder.BorderThickness = new Thickness(2);
            myChildBorder.CornerRadius = new CornerRadius(45);
            myChildBorder.Width = 100;
            myChildBorder.VerticalAlignment = VerticalAlignment.Center;
            myChildBorder.Height  = 100;
            myChildBorder.Padding = new Thickness(25);
            myBorder.Child = myChildBorder;
            this.Content = myBorder;
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            brder();
    }
  
Conclusion:
  I hope, you get some ideas about Border. Thanks for reading this article. We will talk about other controls in next Chapters.              

No comments:

Post a Comment