Created
March 5, 2018 07:25
-
-
Save enisn/25fd0a63a849854fb6103aa681be9963 to your computer and use it in GitHub Desktop.
Xamarin.Forms.Contacts Sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<uses-permission android:name="android.permission.READ_CONTACTS" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<key>NSContactsUsageDescription</key> | |
<string>We need contact permission to do ...</string> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using Xamarin.Forms; | |
namespace Sample.ContactService | |
{ | |
public partial class MainPage : ContentPage | |
{ | |
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed | |
public MainPage() | |
{ | |
InitializeComponent(); | |
GetContacs(); | |
} | |
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed | |
async Task GetContacs() | |
{ | |
var contacts = await Plugin.ContactService.CrossContactService.Current.GetContactListAsync(); | |
lstContacts.BindingContext = contacts; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" ?> | |
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" | |
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | |
xmlns:local="clr-namespace:Sample.ContactService" | |
x:Class="Sample.ContactService.MainPage"> | |
<StackLayout> | |
<ListView | |
x:Name="lstContacts" | |
ItemsSource="{Binding .}"> | |
<ListView.ItemTemplate> | |
<DataTemplate> | |
<ViewCell> | |
<StackLayout> | |
<Label Text="{Binding Name}"/> | |
<Label Text="{Binding Email}"/> | |
<Label Text="{Binding Number}"/> | |
</StackLayout> | |
</ViewCell> | |
</DataTemplate> | |
</ListView.ItemTemplate> | |
</ListView> | |
</StackLayout> | |
</ContentPage> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment