WP8.1 C# Binding Contact Image

后端 未结 4 1082
北荒
北荒 2021-01-07 14:24

Information
Quite simply, I’m attempting to create an app that would display the contacts for a user.

I’m also a self-taught programmer, so I

4条回答
  •  生来不讨喜
    2021-01-07 14:42

        public static BitmapImage GetImage(Contact con)
        {
            if (con == null || con.Thumbnail == null)
            {
                return null;
            }
    
            var bitmapImage = new BitmapImage();
            bitmapImage.DecodePixelHeight = 256;
            bitmapImage.DecodePixelWidth = 256;
    
    
            Action load = async () =>
            {
                using (IRandomAccessStream fileStream = await con.Thumbnail.OpenReadAsync())
                {
                    await bitmapImage.SetSourceAsync(fileStream);
                }
            };
    
            load();
    
            return bitmapImage;
        }
    

提交回复
热议问题