MainPage.xaml
<Page
x:Class="UniversalAppTutorials.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UniversalAppTutorials"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<StackPanel
x:Name="StackPanel1"
Margin="50"
Orientation="Vertical"
Background="AliceBlue"
Padding="50"
>
<Rectangle
Width="300"
Height="100"
Fill="PaleGreen"
Margin="5"
/>
<Rectangle
Width="300"
Height="100"
Stroke="Black"
StrokeThickness="5"
Margin="5"
/>
<Rectangle
Width="300"
Height="100"
Fill="Crimson"
Stroke="Yellow"
StrokeThickness="3"
Margin="5"
/>
<Rectangle
Width="300"
Height="100"
Fill="Pink"
Stroke="CadetBlue"
StrokeThickness="2"
Margin="5"
RadiusX="50"
RadiusY="50"
/>
<Rectangle
Width="300"
Height="100"
Fill="Honeydew"
Stroke="BlueViolet"
StrokeThickness="5"
Margin="5"
RadiusX="10"
RadiusY="45"
/>
</StackPanel>
</Page>
MainPage.xaml.cs
using Windows.UI.Xaml.Controls;
using Windows.UI;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Shapes;
namespace UniversalAppTutorials
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
// Create a rectangle
CreateRectangle();
}
private void CreateRectangle()
{
// Initialize a new rectangle instance
Rectangle rectangle = new Rectangle();
// Set the rectangle height and width
rectangle.Height = 100;
rectangle.Width = 300;
// Fill the rectangle with a solid color
rectangle.Fill = new SolidColorBrush(Colors.Blue);
// Set the rectangle border color
rectangle.Stroke = new SolidColorBrush(Colors.LightSeaGreen);
// Set rectangle border thickness/width
rectangle.StrokeThickness = 5;
// Finally, add the rectangle to layout
StackPanel1.Children.Add(rectangle);
}
}
}