Rectangle - Windows Phone Controls สำหรับ Rectangle เป็น Controls บน Windows Phone ใช้สำหรับการสร้างกล่องสี่เหลี่ยมผืนผ้า (Rectangle) บนหน้าจอ App ของ Windows Phone
XAML
<Rectangle .../>
Example ตัวอย่างการใช้ Rectangle บน Windows Phone
XAML
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="PageTitle" Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentGrid" Grid.Row="1">
<Canvas>
<Rectangle Width="100" Height="100" Fill="Blue" Stroke="Red"
Canvas.Top="128" Canvas.Left="190" StrokeThickness="3" />
</Canvas>
</Grid>
</Grid>
VB.NET
Partial Public Class MainPage
Inherits PhoneApplicationPage
' Constructor
Public Sub New()
InitializeComponent()
Dim Rect As Rectangle = New Rectangle()
Rect.Fill = New SolidColorBrush(Colors.Red)
Rect.Width = 100
Rect.Height = 100
Rect.HorizontalAlignment = System.Windows.HorizontalAlignment.Center
Rect.VerticalAlignment = System.Windows.VerticalAlignment.Center
Me.ContentGrid.Children.Add(Rect)
End Sub
End Class
C#
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
Rectangle Rect = new Rectangle();
Rect.Fill = new SolidColorBrush(Colors.Red);
Rect.Width = 100;
Rect.Height = 100;
Rect.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
Rect.VerticalAlignment = System.Windows.VerticalAlignment.Center;
this.ContentGrid.Children.Add(Rect);
}
}