Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
This is an attempt on Windows Phone 8 to trigger a Contact's Details UI to be displayed by creating a VCF file. This is at the suggestion of @justinangel (http://www.twitter.com/JustinAngel/status/285552040636194816)
private async void listBox_ItemTap(object sender, Telerik.Windows.Controls.ListBoxItemTapEventArgs e)
{
var result = (Contact)e.Item.AssociatedDataItem.Value;
var test = new ContactInformation();
test.GivenName = result.CompleteName.FirstName;
test.FamilyName = result.CompleteName.LastName;
test.DisplayName = result.DisplayName;
var vCard = await test.ToVcardAsync();
var tempName = Guid.NewGuid().ToString() + ".vcf";
var file = await ApplicationData.Current.LocalFolder.CreateFileAsync(tempName);
using (IRandomAccessStream fileStream = await file.OpenAsync(FileAccessMode.ReadWrite))
{
using (IOutputStream outputStream = fileStream.GetOutputStreamAt(0))
{
using (DataWriter dataWriter = new DataWriter(outputStream))
{
var vcardStream = vCard.AsStream();
var cardBytes = new byte[vcardStream.Length];
await vcardStream.ReadAsync(cardBytes, 0, (int)vcardStream.Length);
dataWriter.WriteBytes(cardBytes);
await dataWriter.StoreAsync();
dataWriter.DetachStream();
}
await outputStream.FlushAsync();
}
}
await Launcher.LaunchFileAsync(
await ApplicationData.Current.LocalFolder.GetFileAsync(tempName));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.