TextBox - Windows Phone Controls |
TextBox - Windows Phone Controls สำหรับ TextBox เป็น Control บน Windows Phone ใช้สำหรับการสร้างกล่อง Input Box ไว้รับข้อความต่าง ๆ จากผู้ใช้
XAML
<TextBox .../>
Example ตัวอย่างการใช้ TextBox บน 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="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<TextBlock Height="30" HorizontalAlignment="Left" Margin="148,75,0,0" Name="txtTitle" Text="Input your name?" VerticalAlignment="Top" />
<TextBox Height="72" HorizontalAlignment="Left" Margin="50,111,0,0" Name="txtName" Text="" VerticalAlignment="Top" Width="360" />
<Button Content="Submit" Height="72" HorizontalAlignment="Left" Margin="148,213,0,0" Name="btnSubmit" VerticalAlignment="Top" Width="160" />
<TextBlock Height="30" HorizontalAlignment="Center" Margin="102,329,118,0" Name="txtResult" Text="Result" VerticalAlignment="Top" />
</Grid>
</Grid>
VB.NET
Private Sub btnSubmit_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles btnSubmit.Click
Me.txtResult.Text = "Sawatdee Khun " & Me.txtName.Text.ToString()
End Sub
C#
private void btnSubmit_Click(System.Object sender, System.Windows.RoutedEventArgs e)
{
this.txtResult.Text = "Sawatdee Khun " + this.txtName.Text.ToString();
}
Screenshot
แสดง TextBox และการอ่านค่าจาก TextBox
|