---
title: "TextBox Control in Windows 7 Phone Development"  
description: "With the TextBox control, the user can enter text in an application. Typically, a TextBox control is used to display, or accept as input, a single lin"  
author: "Anonymous User"  
published: 2012-04-13  
updated: 2019-09-07  
canonical: https://www.mindstick.com/articles/921/textbox-control-in-windows-7-phone-development  
category: "windows phone"  
tags: ["windows phone"]  
reading_time: 2 minutes  

---

# TextBox Control in Windows 7 Phone Development

With the [TextBox control](https://www.mindstick.com/articles/320/textbox-control-in-vb-dot-net), the user can enter text in an [application](https://www.mindstick.com/articles/12824/calculator-application-in-android). Typically, a TextBox control is used to display, or accept as input, a single line of text. You can use the Multiline and ScrollBars properties to enable [multiple lines](https://www.mindstick.com/forum/161317/how-can-you-read-multiple-lines-of-input-in-python-efficiently) of text to be displayed or entered. This article is going to explain how to use TextBox control in windows 7 phone development.\

##### Getting started:

1. Open [Visual Studio](https://www.mindstick.com/articles/12378/visual-studio-for-mac-is-out-of-beta-preview-now-officially-available)

2. Create new [Silverlight](https://www.mindstick.com/blog/54/silverlight-in-asp-dot-net) Windows 7 Phone [Development Project](https://www.mindstick.com/blog/11637/how-to-choose-the-right-web-designer-for-your-web-design-development-project)

3. Enter [your project](https://www.mindstick.com/forum/156583/best-way-to-link-bootstrap-file-in-your-project) Name

4. Click on button ‘Ok’

![TextBox Control in Windows 7 Phone Development](https://www.mindstick.com/mindstickarticle/256e0643-e9f7-4d59-b593-df497e4e4f9a/images/f5945e59-652e-4859-a14b-614fb433551f.png)

Now drag and drop Textbox control form toolbox into **MainPage.xaml** design page; after doing this set proper layout of textbox control.

![TextBox Control in Windows 7 Phone Development](https://www.mindstick.com/mindstickarticle/256e0643-e9f7-4d59-b593-df497e4e4f9a/images/696ec12e-ce9a-4a1c-8afe-1971e2a46286.png)

Now write down the following line of code to build this layout;

##### Code of ‘MainPage.xaml’ file:

```
<!--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="Textbox Demo" 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="42" HorizontalAlignment="Left" Margin="30,6,0,0" Name="lblEmpDetails" Text="Employee Details" VerticalAlignment="Top" Width="366" DataContext="{Binding}" FontSize="32" />            <TextBlock Height="50" HorizontalAlignment="Left" Margin="30,75,0,0" Name="lblName" Text="Emp Name" VerticalAlignment="Top" Width="165" FontSize="28" />            <TextBox Height="72" HorizontalAlignment="Left" Margin="191,63,0,475" Name="txtName" Text="" VerticalAlignment="Center" Width="230" />            <TextBlock Height="60" HorizontalAlignment="Left" Margin="35,163,0,0" Name="lblAddress" Text="Address" VerticalAlignment="Top" Width="118" FontSize="28" />            <TextBox Height="72" HorizontalAlignment="Left" Margin="192,150,0,0" Name="txtAddress" Text="" VerticalAlignment="Top" Width="230" />            <TextBlock Height="44" HorizontalAlignment="Left" Margin="36,247,0,0" Name="lblMobNo" Text="Mobile No." VerticalAlignment="Top" Width="144" FontSize="28" />            <TextBox Height="72" HorizontalAlignment="Left" Margin="192,235,0,0" Name="txtMobNo" Text="" VerticalAlignment="Top" Width="229" />            <Button Content="Submit" Height="72" HorizontalAlignment="Left" Margin="176,344,0,0" Name="btnSubmit" VerticalAlignment="Top" Width="160" Click="btnSubmit_Click" />        </Grid>    </Grid>
```

Code of MainPage.xaml.cs file:

```
using System.Windows;using Microsoft.Phone.Controls; namespace textBoxDemo{    public partial class MainPage : PhoneApplicationPage    {        // Constructor        public MainPage()        {            InitializeComponent();        }         private void btnSubmit_Click(objectsender, RoutedEventArgse)        {            if (txtName.Text.Equals(string.Empty) || txtAddress.Text.Equals(string.Empty) ||txtMobNo.Text.Equals(string.Empty))                MessageBox.Show("Please fill all enteries");            else            MessageBox.Show("Data Successfull Submitted");        }            }}
```

\

Now execute [your program](https://answers.mindstick.com/qa/33494/how-do-you-find-any-view-element-into-your-program-explain-for-example); following output will be appearing.

![TextBox Control in Windows 7 Phone Development](https://www.mindstick.com/mindstickarticle/256e0643-e9f7-4d59-b593-df497e4e4f9a/images/a43ca867-617e-4cf3-9966-3bb4b1ae6297.png)

Now fill all appropriate information in textfields and click on button **‘Submit’**.

![TextBox Control in Windows 7 Phone Development](https://www.mindstick.com/mindstickarticle/256e0643-e9f7-4d59-b593-df497e4e4f9a/images/4d423cc1-e179-4912-a90f-d261b40f8a4d.png)

This is the complete description about Textbox control in windows 7 phone development. I hope you will enjoy it.

\

---

Original Source: https://www.mindstick.com/articles/921/textbox-control-in-windows-7-phone-development

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
