我如何在xaml中显示联系人的图片?

时间:2014-07-28 18:33:59

标签: xaml windows-phone-7 windows-phone-8 contacts

void _appContacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
{
    foreach (var result in e.Results)
    {
        var stream = result.GetPicture();

        if (stream != null)
        {
            BitmapImage bmp = new BitmapImage();
            bmp.SetSource(stream);
            Image img = new Image();
            img.Source = bmp;
        }
    }
}

1 个答案:

答案 0 :(得分:-1)

我可以使用以下代码获取联系人的图片,试试这个。

    Contact con;
    private void contactListBox_Tap(object sender, System.Windows.Input.GestureEventArgs e)
    {
        con = ((sender as ListBox).SelectedValue as Contact);

        BitmapImage img = new BitmapImage();
        img.SetSource(con.GetPicture());
        ContactImage.Source = img;
    }

希望它对你有所帮助。