title: Call a contact number for wp7
body: <p>In my contact app(for wp7), i am not able to correct this error at all. I have also added an image below. When i <strong>Tap</strong> on the contact number, am not able to Call that number. I am getting the following error- <strong>NullReferenceException</strong>. I have also used the PhoneCallTask. </p>
  
  <p><img src="https://i.stack.imgur.com/r41rH.png" alt="enter image description here"></p>
  
  <p>In xaml-</p>
  
  <pre><code>&lt;StackPanel x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"&gt;
  
          &lt;TextBlock Text="{Binding Path=DisplayName, Mode=OneWay}" Foreground="{StaticResource PhoneAccentBrush}" FontSize="{StaticResource PhoneFontSizeExtraLarge}" /&gt;
  
          &lt;Border BorderThickness="2" HorizontalAlignment="Left" BorderBrush="{StaticResource PhoneAccentBrush}" &gt;
              &lt;Image Name="Picture" Height="175" Width="175" HorizontalAlignment="Left" /&gt;
          &lt;/Border&gt;
          &lt;TextBlock Height="50" Name="textBlock1" Text="call mobile" FontSize="40" Margin="0,30,0,0"/&gt;
          &lt;ListBox x:Name="ListBox" ItemsSource="{Binding Path=PhoneNumbers}" FontSize="64" Height="100"  Margin="0,0,0,0" SelectionChanged="ListBox_SelectionChanged"&gt;
              &lt;ListBox.ItemTemplate&gt;
                  &lt;DataTemplate&gt;
                      &lt;Grid&gt;
                          &lt;Grid.ColumnDefinitions&gt;
                              &lt;ColumnDefinition Width="Auto"/&gt;
                              &lt;ColumnDefinition Width="Auto"/&gt;
                              &lt;ColumnDefinition Width="*"/&gt;
                          &lt;/Grid.ColumnDefinitions&gt;
                          &lt;!--TextBlock Grid.Column="0" Text="{Binding Path=Kind, Mode=OneWay}" /&gt;
                          &lt;TextBlock Grid.Column="1" Text=":  " /--&gt;
                          &lt;TextBlock Grid.Column="2" Text="{Binding Path=PhoneNumber, Mode=OneWay}" /&gt;
                      &lt;/Grid&gt;
                  &lt;/DataTemplate&gt;
              &lt;/ListBox.ItemTemplate&gt;
          &lt;/ListBox&gt;
      &lt;/StackPanel&gt;
  </code></pre>
  
  <p>In xaml.cs-</p>
  
  <pre><code>protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
      {
          base.OnNavigatedTo(e);
  
          //Set the data context for this page to the selected contact
          this.DataContext = App.con;
  
          try
          {
              //Try to get a picture of the contact
              BitmapImage img = new BitmapImage();
              img.SetSource(App.con.GetPicture());
              Picture.Source = img;
          }
          catch (Exception)
          {
              //can't get a picture of the contact
          }
      }
  
      private void ListBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
      {
          SampleData data = (sender as ListBox).SelectedItem as SampleData;
          ListBoxItem selectedItem = this.ListBox.ItemContainerGenerator.ContainerFromItem(data) as ListBoxItem;
          PhoneCallTask PhoneTask = new PhoneCallTask();
          PhoneTask.PhoneNumber = data.PhoneNumbers;
          PhoneTask.Show();
      }
  
      public class SampleData
      {
          public string PhoneNumbers { get; set; }
      }
  </code></pre>
  
  <p>Can anybody help me with this? Thanks in advance for your hard work!</p>