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:
BordermyBorder;
private void brder()
{
myBorder = newBorder();
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;
}
privatevoid Window_Loaded(objectsender, 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;
BordermyChildBorder;
privatevoid brder()
{
myBorder = newBorder();
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;
}
privatevoid Window_Loaded(objectsender, 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