How to make a call in Windows Phone 7



In this article, I am going to describe how to make a call in windows phone 7 using managed API.

Objective of this article to make a call programmatically, sometimes application has specific requirement to make a phone call from application; in that scenario we can take the leverage of Microsoft managed API Microsoft.Phone.Tasks (namespace) allows to access PhoneCallTask API to make a call in windows phone.

Basically PhoneCallTask API allows an application to launch the Phone application. Use this to allow users to make a phone call from your application.

Let’s take an example to make a phone call from application. Add a Button to the default XAML which is gifted by MS Visual Studio when you start a new Windows Phone 7 Silverlight application. See the below xaml here.


<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
      <Button Content="Phone Call" Height="82" HorizontalAlignment="Left" Margin="140,234,0,0" Name="btnCall" VerticalAlignment="Top" Width="auto" Click="btnCall_Click" />

XAML will generate the UI (user interface) that look like see below screen.


Now initialize the PhoneCallTask task object in the constructor of page, to avoid the memory overhead so I initialized in the constructor.

PhoneCallTask phoneTask = null;

// Constructor
public MainPage()
    phoneTask = new PhoneCallTask();            

The PhoneCallTask class contains two core properties like DisplayName, PhoneNumber and one show method, which allows us to shows the phone application. To make an actual call though the application.

Now double click the button control and click event handler got added to button control object. In the button click event set the display name and phone number which you want to make a call. And calls a *Show()* method of phone task object. See below mentioned code snippet.

private void btnCall_Click(object sender, RoutedEventArgs e)
  phoneTask.DisplayName = "Pavan Pareta";
  phoneTask.PhoneNumber = "+911234567890"; // put your desired phone number here

Now the application is get ready to execute. When the user clicks on the button, phone dial will appear the phone user has to click the on *call* button then only we can make a call.

See blow screenshots


Download source code here.

Thank you for your time.


About Pavan Pareta

My name is Pavan Pareta, I enjoy computers and general technology. I am more interested in the areas of Computer Security, Programming and developing innovative s/w for Windows Mobile and Windows Phone 7. I like MS Technology and support open-source software, because I believe it plays a major role in knowledge sharing and exchange of ideas, which effectively leads to better software. Additionally, I am a follower of the KISS (Keep It Simple Stupid) philosophy. I Love C#.NET and recently I am fall in love with Silverlight :) Introduce to my machine My main workstation is a Intel Pentium Core Duo and my primary operating system is Windows 7.
This entry was posted in Introducing Windows Phone 7 Series, Launchers and Choosers, Mango, Windows Phone 7, Windows Phone APIs. Bookmark the permalink.

One Response to How to make a call in Windows Phone 7

  1. Excellent pieces. Keep posting such kind of information on your blog. I really impressed by your blog. IPhone App Development| Android apps developer

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s