引用命名空间: using Windows.System.UserProfile; 

1、获取用户头像信息:

  

            // The small picture returned by GetAccountPicture() is 96x96 pixels in size.
            StorageFile image = UserInformation.GetAccountPicture(AccountPictureKind.SmallImage) as StorageFile;
            if (image != null)
            {
try
                {
                    IRandomAccessStream imageStream = await image.OpenReadAsync();
                    BitmapImage bitmapImage = new BitmapImage();
                    bitmapImage.SetSource(imageStream);
                    smallImage.Source = bitmapImage;
                }
                catch (Exception ex)
                {
                    
} }

 获取大头像只需把第一句改为:

  // The large picture returned by GetAccountPicture() is 448x448 pixels in size.
  StorageFile image = UserInformation.GetAccountPicture(AccountPictureKind.LargeImage) as StorageFile;

获取用户的 mp4 用户视频:

// The video returned from getAccountPicture is 448x448 pixels in size.
            StorageFile video = UserInformation.GetAccountPicture(AccountPictureKind.Video) as StorageFile;
            if (video != null)
            {
try
                {
                    IRandomAccessStream videoStream = await video.OpenAsync(FileAccessMode.Read);

                    mediaPlayer.SetSource(videoStream, "video/mp4");
                    mediaPlayer.Visibility = Visibility.Visible;
                }
                catch (Exception ex)
                {
                   
} }

 

 2、获取当前用户名:

 string displayName = await UserInformation.GetDisplayNameAsync();

用户的 FirstName:

 string firstName = await UserInformation.GetFirstNameAsync();

用户的 LastName:

 string lastName = await UserInformation.GetLastNameAsync();

 

相关文章:

  • 2021-08-18
  • 2021-07-07
  • 2022-12-23
  • 2022-03-01
  • 2021-12-25
  • 2022-12-23
  • 2021-12-07
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-20
  • 2022-12-23
相关资源
相似解决方案