---
title: "Password Control in Windows Phone 7 Development"  
description: "This article is going to explain how to use Password control in Windows 7 phone development. Let’s see a brief demonstration on it."  
author: "Anonymous User"  
published: 2012-04-15  
updated: 2019-09-07  
canonical: https://www.mindstick.com/articles/924/password-control-in-windows-phone-7-development  
category: "windows phone"  
tags: ["windows phone"]  
reading_time: 1 minute  

---

# Password Control in Windows Phone 7 Development

This article is going to explain how to use **[Password](https://www.mindstick.com/blog/118/retriving-user-password-by-using-stored-procedure-in-asp-dot-net)** [control](https://yourviews.mindstick.com/view/83439/bipartisan-gun-control-bill-passed-in-us-after-decades) in Windows 7 phone development. Let’s see a brief demonstration on it.\

##### 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’

![Password Control in Windows Phone 7 Development](https://www.mindstick.com/mindstickarticle/50b715de-64da-40dc-9ad9-f397a6739d66/images/629d10ba-6f31-4d69-9a6f-531685fb05a5.png)

Now drag and drop **Password** control in ‘MainPage.xaml’ design interface and set some properties of **Password** control.

![Password Control in Windows Phone 7 Development](https://www.mindstick.com/mindstickarticle/50b715de-64da-40dc-9ad9-f397a6739d66/images/167c24d6-d42f-4e07-b9c2-384df95a6a5b.png)

Now write down the following to code to build up above layout.

##### Code of MainPage.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="PasswordControl Demo" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}" FontSize="40" />        </StackPanel>         <!--ContentPanel - place additional content here-->        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">            <TextBlock Height="48" HorizontalAlignment="Left" Margin="30,68,0,0" Name="lblUsername" Text="UserName" VerticalAlignment="Top" Width="171" FontSize="32" />            <TextBlock Height="56" HorizontalAlignment="Left" Margin="30,170,0,0" Name="lblPassword" Text="Password" VerticalAlignment="Top" Width="171" FontSize="32" />            <TextBox Height="72" HorizontalAlignment="Left" Margin="180,58,0,0" Name="txtUsername" Text="" VerticalAlignment="Top" Width="238" />            <PasswordBox Height="72" HorizontalAlignment="Left" Margin="180,158,0,0" Name="txtPassword" VerticalAlignment="Top" Width="238" />            <Button Content="Login" Height="90" HorizontalAlignment="Left" Margin="180,290,0,0" Name="btnLogin" VerticalAlignment="Top" Width="180" Click="btnLogin_Click" />        </Grid>z    </Grid>
```

Code of MainPage.xaml.cs:

```
using System.Windows;using Microsoft.Phone.Controls; namespace passwordDemo{    public partial class MainPage : PhoneApplicationPage    {        // Constructor        public MainPage()        {            InitializeComponent();        }         private void btnLogin_Click(objectsender, RoutedEventArgse)        {            if (txtUsername.Text.Equals(string.Empty) || txtPassword.Password.Equals(string.Empty))                MessageBox.Show("Please fill all enteries!");            else            {                if (txtUsername.Text.Equals("arunSingh") && txtPassword.Password.Equals("arun@123"))                    MessageBox.Show("login successfully");                else                    MessageBox.Show("login failed!");            }                       }    }}
```

\

\

Now execute [your application](https://answers.mindstick.com/qa/95487/how-do-you-troubleshoot-when-your-application-link-is-not-responding).

![Password Control in Windows Phone 7 Development](https://www.mindstick.com/mindstickarticle/50b715de-64da-40dc-9ad9-f397a6739d66/images/5a13ad03-2082-4391-97ca-0f1290fb44be.png)

Now click on button **‘Login’**.

![Password Control in Windows Phone 7 Development](https://www.mindstick.com/mindstickarticle/50b715de-64da-40dc-9ad9-f397a6739d66/images/77551a95-0d91-448e-85e2-efb2de994fbf.png)

This is the complete description of Password control in Windows Phone 7 Development. I hope you will enjoy it. Thanks for reading this article.

\

\

\

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